Changes to a Script

Hello, I have a script that I'm hoping that someone could help me change a few problem spots with it ?

It's the last script I need to get sorted out so I can use.  One of the few problems is the script needs to save the LayerGroup based on a Keyboard Shortcut, for example GrapeA LayerSet would be a keyboard shortcut etc, but it must only save based on the LayerGroup name in other words each LayerGroup has it's only Keyboard short-cut and there are (5) LayerGroups that the script knows to only find.
The second problem is the file name must be saved out as <FileName>_<LayerGroupName>.PSD only.
main();
// It calls the other functions to change the visibility of the layer, duplicate it
// another document in PSD format and save the document.
function main(){
if(documents.length > 0 && app.activeDocument.activeLayer.typename == "LayerSet") {
// define the layer names;
var theArray = ["GrapeA", "GrapeB", "GrapeC", "GrapeD", "GrapeE"];
var savePath = decodeURI(activeDocument.path);
var theFileName = app.activeDocument.name;
// thanks to xbytor for the regexp;
var baseName = theFileName.match(/(.*)\.[^\.]+$/)[1];
// work through the array;
for (var m = 0; m < theArray.length; m++) {
var layerName = theArray[m];
// set the active layer to the layer of the name from the array;
// works only if the layersets are op level in the document;
app.activeDocument.activeLayer = app.activeDocument.layers.getByName(layerName);
var theFile = dupLayers();
var SaveFile= File(savePath+"/"+baseName+"_"+layerName+".psd");
SavePSD(SaveFile, theFile);
theFile.close(SaveOptions.DONOTSAVECHANGES);
else {alert ("please open a document and select a layer group")}
//changes the view from visible to hidden and vice-versa
function toggleLayerView(name){
    var actionTaken = charIDToTypeID( "Shw " );
    var actDescription = new ActionDescriptor();
    var id22 = charIDToTypeID( "null" );
        var actList = new ActionList();
            var actReference = new ActionReference();
            var objectType = charIDToTypeID( "Lyr " );
            actReference.putName( objectType, name );
        actList.putReference( actReference );
    actDescription.putList( id22, actList );
    var id24 = charIDToTypeID( "TglO" );
    actDescription.putBoolean( id24, true );
executeAction( actionTaken, actDescription, DialogModes.NO );
var al = activeDocument.layers.getByName(name);
   if(al.typename == 'LayerSet'){
       for(i=0;i<al.layers.length;i++){
                al.layers[i].visible=!al.layers[i].visible;
//copies the layers in a new document
function dupLayers() {
        var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
        desc143.putReference( charIDToTypeID('null'), ref73 );
        desc143.putString( charIDToTypeID('Nm  '), "_"+activeDocument.activeLayer.name+".psd" );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
//selects the layer
function selectLayerByName(name) {
        var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putName( charIDToTypeID('Lyr '), name );
       desc.putReference( charIDToTypeID('null'), ref );
       desc.putBoolean( charIDToTypeID('MkVs'), false );
       executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
//saves the file in PSD format
function SavePSD(saveFile){
          psdSaveOptions = new PhotoshopSaveOptions();
          psdSaveOptions.embedColorProfile = true;
         psdSaveOptions.alphaChannels = true;
         activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);

Similar Messages

  • How to change maintenance powershell script via GPO?

    Per suggestion reposted from here: http://social.technet.microsoft.com/Forums/windowsserver/en-US/6eece9d6-a524-48aa-8e64-7554f0ec9b31/how-to-change-maintenance-powershell-script-via-gpo?forum=winserverGP
    Posted at http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/desktop-shortcuts-to-items-on-network-drives/94eddb27-342b-40fc-9ad4-677ff4ee8ebe?page=9&tm=1403700614489 originally.
    There is a very annoying "feature" in Windows 7 called BrokenShortcuts.ps1 which is being called out weekly via maintenance task and if it finds more than 4 "broken" network shortcuts it removes them all. So it means if a user at this
    moment is disconnected from the network he will lose all links to shares, network applications sitting on his desktop. Funny that there was no such script on Vista and i don't see this on Win8. On the post i have attached one user suggested to edit this script
    and change 4 to 500 or whatever high number. That's fine for one time fix. But i need to do this for 200+ users. This file cannot be simply replaced by a script, so i'm wondering is there any way to do it via GPO?
    I have already tried various startup scripts, but i'm not sure which user to put into commands.
    I need to run this on startup:
    takeown /F C:\Windows\diagnostics\scheduled\Maintenance\TS_BrokenShortcuts.ps1
    icacls c:\windows\diagnostics\scheduled\maintenance\TS_BrokenShortcuts.ps1 /grant "some user":F
    copy \\share\folder$\TS_BrokenShortcuts.ps1 C:\Windows\diagnostics\scheduled\Maintenance\ /Y

    You need to take time to study how Windows does these things.  You can control them with GP which is what you asked.  The article shows you how to disable elements of the tasks.  Each task controls a script.  If you disable the task the
    script that deletes shortcuts will be stopped. Other maintenance tasks will continue to run.
    Most of your problem is that you seem to want someone to provide a magical solution.  In technology it is necessary to fully research your issues until you understand all aspects.  After fully studying the issue you should understand the possible
    solutions if they exist.
    You claim to have deployed the patch that Microsoft released to fix the issue.  You claim it didn't work.  If that is the case then you need to call MS and \p[en a support incident.  If  Microsoft determines that you are right about the
    patch not working you will not be charged for the call.
    I know that learning how to support technology is hard and frustrating for newcomers.  In time, by using these incidents to learn, you will become a seasoned technician and all of this will seem trivial.  Until then we can only suggest that you
    do things that most of us are familiar with.  We cannot fix your network for you.
    I think you haven't really posted in the GP forum but posted a question about GP in the server forum.  Try posting in the GP forum.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverGP
    Here is one answer from the GP forum:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverGP
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/600ca14f-8b1b-400c-b27f-a7f5733407ac/windows-scheduled-maintenance-task?forum=winserverGP
    ¯\_(ツ)_/¯

  • An error prevents the Change Management Upgrade script from executing

    I have Warehouse Builder 10g on a database 10g R1.
    On a server linux I have the repository, and on other server (Sun 5.9) I have runtimes for production.
    I want execute an upgrade deploy action on one object but I get this error:
    An error prevents the Change Management Upgrade script from executing successfully. We strongly advise that this Upgrade is UNDONE and the problem is investigated. Data loss may occur if you accept this Upgrade
    Any idea?
    Thanks,
    Fernando.

    I review the installation, it was made with a diferent user that database, I get same permission, restart runtimes service and problem was resolved.
    Fernando.

  • Could not save changes to this script because of a program error. -2706

    OK, this is very odd! Please try the following and let me know your results:
    1) Create a new script with the following example code:
    set testList to {}
    repeat with i from 1 to 8145
    copy i to end of testList
    end repeat
    2) Save the script as an Application (name it whatever you like).
    3) Launch the newly created Application and see if you get the same error message I am getting...
        *Could not save changes to this script because of a program error.*
        -2706
    If you replace the number 8145 with 8144 (or any number less than 8145) the script runs without error. Any number greater than 8144 returns the error message shown above. Maybe there's a reason for this that I'm overlooking or is this another bug?
    I looked up error code -2706 ([HERE|http://developer.apple.com/Mac/library/documentation/AppleScript/Concept ual/AppleScriptLangGuide/reference/ASLRerrorcodes.html]) which says it is a "*Stack overflow.*"
    Thanx in advance for any insight on this!!
    NOTE:
    The only workaround I've found for this is to make sure the script resets the variable before it quits. Like this:
    set testList to {}
    repeat with i from 1 to 8145
    copy i to end of testList
    end repeat
    set testList to ""

    Hey Pierre, thanx for taking the time to scratch your head with me!
    Very odd indeed.
    Glad it's not just me that thinks this!
    I've also noticed that the problem occurs even when you try to save the script as a compiled script. That's possible as long as you haven't run the script. Once you have run it, trying to save it seems impossible. You get the message: *“The document “Document title” could not be saved.”*
    I've noticed the same thing as you and have experienced this extra error several times while trouble shooting this problem!
    On the other hand, is there any good reason for which you would want to save such a big list? Are there any drawbacks to the workaround you've found?
    I don't want to save ANY variable EVER unless I explicitly tell my script to do so! This variable is not a property, so why would my script want to save it? I haven't noticed any drawbacks to the workaround. Setting the list variable to "" or {} (or ANYthing with under 8145 items) seems to work fine. I just find it weird that my script can't "*save changes to itself*"?! What is there to save? It's just a variable that should release after my script has run ...unless I'm completely misunderstanding how variables work after ALL these years of scripting.
    Btw, the following version of the script (as you probably already know) is much faster, although it doesn't change anything to the result:
    *set testList to {}*
    *set testListRef to a reference to testList*
    *repeat with i from 1 to 8144*
    *copy i to end of testListRef*
    *end repeat*
    Yeah, it definitely runs much faster this way! I just posted a quick example that would illustrate the 8144 list count limit. My script sets a variable to a list of numbers contained in a text file. This list is almost always rather large! Right now there are over 20,000 items in this list of numbers.
    Again, thanx for your time my friend!!

  • Change the SAP Script Package

    Hi,
    How to change the SAP Script Package..when i use option copy from client option, it ask for a package but after copied it shows in the $TMP package...
    how can i change it.
    Regards,

    Hi,
    Goto SE80 --> select LOCAL OBJECTS from the drop down and hit enter.
    You will be displayed a list of all local objects.
    Locate your SAP SCRIPT --> right click on this script name --> click More Functions --> click Change Package Assignment and you will be prompted for a package name.
    Give new package name and click done.
    Your script is now assigned into the specified package.
    Regards,
    Tarun

  • Can we change the test scripts in TCK (JavaCard tests for compatibility)

    Hi everyone,
    I would appreciate if anyone can tell me if we can change the test scripts when testing JavaCards using TCK. Lets say we want to introduce few more APDU's to the test script which already is present in a precompiled format. Can we somehow add to the script and then compile it again.
    Any help would be highly appreciated.
    Thanks,
    AQ

    Read the JC-TCK documentation:
    JC2 Some Conformance Tests may have properties that may be changed.Properties that
    can be changed are identified in the TCK configuration interview. Apart from
    changing such properties and other allowed modifications described in this User’s
    Guide (if any), no source or binary code for a Conformance Test may be altered in
    any way without prior written permission. Any such allowed alterations to the
    Conformance Tests would be posted to the Java Licensee Engineering web site and
    apply to all licensees.

  • [svn] 978: More changes to Ant scripts.

    Revision: 978<br />Author:   [email protected]<br />Date:     2008-03-27 17:54:17 -0700 (Thu, 27 Mar 2008)<br /><br />Log Message:<br />-----------<br />More changes to Ant scripts.<br /><br />1. They now use the <mxmlc> task (rather than <java>) to compile SWFs such as checkinapp.swf.<br /><br />2. I added comments to explain why the <taskdef> that loads <compc> and <mxmlc> from flexTasks.jar needs to be inside the <target> rather than simply in the <project>. (The reason is that our build process builds flexTasks.jar, so we can't load it until after certain targets have executed.)<br /><br />3. All build.xml files within the 'frameworks' directory are now consistent about the following:<br /><br />a. They define FLEX_HOME.<br />b. They load FLEX_HOME's build.properties file.<br />c. They refer to all files and directories as either ${basedir}/foo/bar (for things inside the subdirectory where the script lives) or ${FLEX_HOME}/foo/bar (for things outside that subdirectory).<br /><br />Modified Paths:<br />--------------<br />    flex/sdk/trunk/build.properties<br />    flex/sdk/trunk/build.xml<br />    flex/sdk/trunk/frameworks/build.xml<br />    flex/sdk/trunk/frameworks/projects/airframework/build.xml<br />    flex/sdk/trunk/frameworks/projects/flash-integration/build.xml<br />    flex/sdk/trunk/frameworks/projects/flex/build.xml<br />    flex/sdk/trunk/frameworks/projects/framework/build.xml<br />    flex/sdk/trunk/frameworks/projects/haloclassic/build.xml<br />    flex/sdk/trunk/frameworks/projects/rpc/build.xml<br />    flex/sdk/trunk/frameworks/projects/utilities/build.xml<br />    flex/sdk/trunk/frameworks/tests/checkinapp/build.xml

    I just found the AppleScript documentation in /Applications/Adobe Photoshop CS5/Scripting/Documents/. But I don't think it's even accurate. Here's a very simple sample they give:
    tell application "Adobe Photoshop CS5"
         filter current layer of the current document using lens blur with options {class:lens blur, radius:13}
    end tell
    If I enter this in AppleScript Editor and try to compile it, it selects the word "current" and tells me "Expected end of line but found identifier." It doesn't even recognize "filter" as a command. If I just change that 5 to a 4, it works fine in CS4.
    Here's one way to run a JavaScript file from AppleScript:
    tell application "Adobe Photoshop CS5" to open file "Path:to:file.jsx"
    Of course there's no way to pass any arguments this way, so that greatly limits its usefulness. But perhaps this will be helpful to some people. I'm assuming the JavaScript stuff all works fine, as that seems to be their focus these days.
    The really strange thing is that certain things seem to work fine in AppleScripts that are already compiled (using CS4). But if I try to re-save those scripts with CS5 installed, I get errors.

  • How to change a SAP script output without changing Print Program

    Hi,
    I want to change output of standard PO report printing object. I have to change the ZSAPSCRIPT but I have to keep the print program intact. please give me ideas.

    Hi for that you have to do following.
    1. Create a ZPROGRAM
    2. Write a Perform in your SAP Script.
    3. Write Form inside it your ZPROGRAM.
    Hope this will help you.
    <i><b>Reward points for helpful ans.</b></i>

  • GREP 'find/change' by list script: find a text string containing different para styles

    Hi
    I'm don't write scripts but do 'enjoy' copying, pasting and changing existing code/txt files.
    I have built a GREP find/change .txt that performs a large number of text edits/changes.
    But I'm left with an issue where I have paragraphs of text (styled earlier in the .txt file) that I'm unable to identify using GREP the usual way. I need to identify text in a particular paragraph style, followed by text in another paragraph style.
    Is it possible with GREP to create a search string to find: text styled with one paragraph style, ending with a paragraph return, and to include in that selection the following paragraph/s styled with another paragraph style?
    MTIA Steve

    seb400 napisał(-a):
    What do you mean by I would mark "changing" in "copying, pasting and changing"?
    Hi Steve,
    I mean I can see a way by modifying some existing code with "find...change" job
    1. set criteria to findGrep
    2. store findGrep() in an array
    3. check each found object if next paragraph matches some new criteria
    4. run changeGrep() if true
    Jarek

  • Committing changes within a script

    I've noticed that changes made in a script all go into a single action if the user chooses to manually 'undo' the last change.
    Also, an event like setting document.selection to null doesn't clear out the selected flags for all selected objects until after the current script ends.
    So, if a group is selected and document.selection is set to null then selection.length will be zero but every pageItem in the group will still have selected = true. If I select the same group item again using the script the selected.length won't be 1, it'll be the total number of objects in the selected group. If I start the script with no selection then the selected.length will be 1.
    Is there any method to "commit" changes mid-script or do I have to execute commands I want committed as individual actions as separate scripts or separate doJavaScript actions?
    Thanks!

    I too have noticed with scripts that a single comm+z to undo will undo the whole script. I have not tested with any of you other cases but if you have the app redraw then this undo's OK.
    #target illustrator
    var docRef = app.activeDocument;
    with (docRef) {
         pathItems[0].fillColor = swatches.getByName('CMYK Green').color;
         redraw();
         pathItems[0].fillColor = swatches.getByName('CMYK Cyan').color;
         redraw();
         pathItems[0].fillColor = swatches.getByName('C=15 M=100 Y=90 K=10').color;
         redraw();
    You will need those named swatches available to test…

  • Change screen resolution script.

    I'm trying to make a script to change the resolution of my screen from the current to a different one and back to the first. I need this to make some tests in my new monitor.
    I've looked everywhere, but apparently it's not as simple as I thought!
    To sum, the script should:
    (My current res is 1280x720 at 60Hz in Millions of Colors
    1) Set the resolution to 800x600 at 60Hz in Millions of Colors
    2) Wait 3 seconds
    3) Set the resolution back to 1280x720 at 60Hz in Millions of Colors
    That's it! Shoud be fairly simple to anyone with some applescript knowledge, obvioulsy NOT ME!!!
    TIA.
    P.S. - I'm on Tiger in a PowerMac Quicksilver. Both resolutions are supported on the Mac and monitor. I've tried manually.

    check out macosxhints - Set monitor resolution via AppleScript

  • SimpleText voice changes within the script, is this possible?

    I have just wet myself laughing at the "voice" reading my written text in SimpleText - Bruce and Fred etc. Now would like to have two different voices reading my text as if there were actors. Is it possible to change the voices with the text?
    example:
    [Fred voice] hello I'm the fred voice
    [Bruce] and I'm the sound fo bruce
    [Fred] yes and now back to me
    I'm running and old PPC 4400 and OS9
    I would imagine it is, either by using a particular app or by adding some script. Any suggestions?

    Thanks for the details.
    I debugged the process and can see this line is providing the text on the tab. However, the method is making a low-level call to get the details from some message class/table, but I can't identify what this message class/table is.
    But it looks like it's the sotr_edit transaction, as you mentioned, that controls this. I'm not that familiar with this OTR process though and the transaction is not that intuitive. I assume that I just need to somehow add new entry, with my own Z package.
    Many thanks for the advice though, I knew nothing about that transaction. I also have to create another Online factsheet as well, and it looks like I can control it this way as well.
    I had already modified table CRMV_PRN_CONTROL via sm30 and had changed the values for the Fom name and class/interface from CRM_ACC_ACCOUNT_OVERVIEW_PRN to ZCRM_ACC_ACCOUNT_OVERVIEW_PRN for the form name and from CL_UIU_PRN_ACCOUNT to ZCL_UIU_PRN_ACCOUNT for the class/interface against all the roles.
    However, I know want to add another form name and class/interface as I have TWO user PDF Factsheets to use, depending on which item the user chooses from the Tab.
    Any idea how I can control this?.
    Best regards
    Jason

  • Is it possible to change the Presets Scripts Folder Location?

    Hi,
    I work with Photoshop on a daily basis for my job, but my company has the C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts folder admin-locked (due to it's location in the Program Files folder. I've already asked IT, but they told me that they are unfortunately unable to give me access to that folder because my user profile can't be given admin-rights (due to company policy). I'd really like to change the location of the scripts folder so that I can add some scripts of my own to be able to use in Photoshop.
    Is this possible or is there any sort of workaround?
    Thank you all in advance!

    You can always use browse to go to a different location - I know it's not ideal, but it does tend to remember that folder once you navigate to it.  I would push your IT people about getting you access to that folder.  I also work in for a company that severely limits access to program files, but I made my case that I need to have access to the Photoshop subfolders to do my job.  They should be able to grant you access to just that folder.

  • Day light saving changes in UCCX scripting.

    Hi, We are using UCCX version 8.X  and we have script like press 1 to go shangai tem, press 2 to go to US team like that.
    In the time of day light saving we are doing manual changes in time of day settings manually when ever the location day light savings changes.
    so is there a way to the script refer the local time zone according to the region day light savings.
    or the reqired OS patched time zone patches will solve the problem please suggests.
    Thank you.
    Baskaran.

    Hi,
    UCCX uses its own time in the server to lookup the time. you need to configure the proper timezone for your UCCX. if shangai and US change start using daylight saving at the same date, you don't need to change your script. if not, unfortunately you need to change the time in the script itself.
    HTH
    Anas
    please rate if it is helpful

  • Changing an action script from 2.0 to 3.0 & Flash 5 to the latest??

    I have an action script 2.0 that I need to change to 3.0 and was wondering how to do that.  Also wondering since I did this a number of years ago, I need to have my Tsunami menu updated to the latest Flash movie.  Is there a way to do this?

    you have to understand as2 code so you can see what's being done and then you must understand as3 code so you can rewrite it.  there are some automated conversions that can accomplish some of that but i haven't seen any that are less time-consuming that doing it the long way.

Maybe you are looking for

  • Billing Block removal not updated in the sales order change log

    Hi Gurus, A specific Billing Block is automatically assigned to the sales document header (VBAK-FAKSK) when the net value of the sales order is negative. This is an order related billing. Sometimes the Billing block is getting released automatically

  • Having trouble with my browser :(

    I ordered a bb from uk since they dont have them in estonia. so here is no bis or bes :/ but it should work. my internet. the only option is hotspot browser but i need internet browser. how can i get it? I really need it! 

  • Roles are not inheriting....

    Hi all, I changed my UME configuration to make it point to new datasource. In the new datasource, i am using muliple objectclasses (organizationalunit, country and locality)to represent principal group. Now i can see all branches ,which belongs to ei

  • Change Unit of Measurement

    how to make stock of material zero, without issuing it.

  • Patch 5726010 adcrtbsp.sql script during up-grade to R12

    Dear All, Oracle EBS 11.5.9 with Windows 2003 as a R-12 upgrade process i have downloaded patch 5726010 and executed @adgncons.sql apps apps scripts. its created adcrtbsp.sql for creation of consolidated tablespace model and increases tablespaces whi