Getting the name of the Action that runs this script

If I create a action in photoshop to run a script called "test script", How can I determine within the "test script" what action name started running this script?  I'm trying to write a script to scale my images.  The scaling will be determined by what Action ran this script.
Example
Action Names are 5x7, 4x6, 8x10
Eash action above will run the same script called "scale me"
Within "scale me", the java code will determine that 4x6 started running "scale me"
"scale me" will go to the section within the java code to scale the image loaded in Photoshop to a 4x6 size.
The reason for writing the "scale me" code this way is that I can maintain only one script to scale my images.
Any suggestions or help would be appreciated.
Raymond

Thanks for all your comments.  Micheal, I took your code for the "ActionReference()" object and it works great!  I completed my code and it is working okay (some more testing needed).
*  My Scaling Impage Script  */
var docRef = app.activeDocument;  //Pointer to current opened document
finish:
if (documents.length == 0)      // Check to see if image opened if not, error message
            alert('There are no opened images\r\r' +"Exiting Script");
            break finish;
var savedState = docRef.activeHistoryState      // Save the history state
var originalUnit = preferences.rulerUnits   // Save the existing ruler perferences - units
var ref = new ActionReference();  //Pointer to current selected Action
ref.putEnumerated( charIDToTypeID("Actn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  // Point to selected Action
var desc = executeActionGet(ref);
var actionName = desc.getString( charIDToTypeID("Nm  ") );  // Get Name of seclected Action
var actionSetName = desc.getString( charIDToTypeID("PrNm") ); // Get Group the selected Action belongs to
var actionnumber = 100;    //actionname =  100  (No Action Defined as default)
var portraitorienation = 0;  // Orientation default to portrait
var resolutions = 300;  // resolution default to 300
var sizeh = 999999;  // default size
var sizew = 999999;  // default size
var resolution = 300;
var scaleup1 = 0;  //enlargement
var scaleup2 = 0;  //enlargement
var scaleflag = 0;
var scaleflagg = 0
//  Assumption is the long side is always defined in sizeh
if (actionName=="4 x 5") { actionnumber =0;  sizeh = 1535; sizew = 1228;}
if (actionName=="4 x 6") { actionnumber =1;  sizeh = 1842; sizew = 1228;}
if (actionName=="5 x 7") { actionnumber =2;  sizeh = 2149; sizew = 1535;}
if (actionName=="6 x 9") { actionnumber =3;  sizeh = 2127; sizew = 1842;}
if (actionName=="8 x 10") { actionnumber =4;  sizeh = 3020; sizew = 2416;}
if (actionName=="8 x 12") { actionnumber =5;  sizeh = 3624; sizew = 2416;}
if (actionName=="11 x 14") { actionnumber =6;  sizeh = 4228; sizew = 3322;}
if (actionName=="12 x 18") { actionnumber =7;  sizeh = 5436; sizew = 3624;}
if (actionName=="12 x 24") { actionnumber =8;  sizeh = 7248; sizew = 3624;}
if (actionName=="12 x 36") { actionnumber =9;  sizeh = 10872; sizew = 3624;}
preferences.rulerUnits = Units.PIXELS
var doch = parseInt (docRef.height);
var docw = parseInt (docRef.width);
scaleflag = doch-docw;
if ( doch > docw ) { scaleflagg =1}
if  (scaleflagg == 0)
                portraitorienation = 1;  // Landscape Orientation
                //alert("Seclected Landscape")
                //alert(doch+" Height" +docw +" Width")
var scale1 = docw - sizeh
var scale2 = doch - sizeh
if (docw > sizeh) {scaleup1=1}
if (doch > sizeh) {scaleup2=1}
// We know know what action was started (What size to scale to and the orientation - Landscape or Portrait)
      //      alert ( "Current selected action is: "+actionName+"\r\rin the action set: "+actionSetName +"\r\rAction Number is " +actionnumber +"\r\rDeminsions are (HxW):  "  +sizeh +", "+sizew );
        if (portraitorienation == 1)   //landscape if true
                        if (scaleup1 == 1)
                                        alert ( "This Photo is landscape\r\r"+ "The doc H x W are:  " +doch +" x " + docw +"\r\r" +"Resizing to (H X W:  " +sizew +", "+ sizeh + "\r\r"  + "Reduction");                               
                                        docRef.resizeImage (sizeh, undefined, resolution, ResampleMethod.BICUBICSHARPER)  // Reduction in size
                        else
                                        alert ( "This Photo is landscape\r\r"+ "The doc H x W are:  " +doch +" x " + docw +"\r\r" +"Resizing to (H X W:  " +sizew +", "+ sizeh + "\r\r"   + "Enlargement");                                       
                                        docRef.resizeImage (sizeh, undefined, resolution, ResampleMethod.BICUBICSMOOTHER)  //Enlargement in size
        else  // portrait
                    if (scaleup2 ==1)
                                        alert ( "This Photo is Portrait\r\r"+ "The doc H x W are:  " +doch +" x " + docw +"\r\r" +"Resizing to (H X W:  " +sizeh +", "+ sizew + "\r\r"  + "Reduction");                                                 
                                       docRef.resizeImage (undefined, sizeh, resolution, ResampleMethod.BICUBICSHARPER)
                        else
                                        alert ( "This Photo is Portrait\r\r"+ "The doc H x W are:  " +doch +" x " + docw +"\r\r" +"Resizing to (H X W:  " +sizeh +", "+ sizew + "\r\r"   + "Enlargement");
                                        docRef.resizeImage (undefined, sizeh, resolution, ResampleMethod.BICUBICSMOOTHER)
preferences.rulerUnits = originalUnit  // Restore ruler perferences - units
My script is a single file that is run by the Actions, I've created for each size and each action runs the same script.  When the script runs, it determines via "ActionReference();" what the current selected Action name is and then applies the scaling.  This script has logic for landscape and portrait and will scale using the different algorithms (bicubic xxxx) depending if it is reducing the image or enlarging.   The parametersfor the scaling is long side and constraint proportions.
So if I have to add another size to the code, all I need to do is to add one line of code to the script, copy any of the existing Actions and rename the copied Action to the size and I am done.
I'm not a experience programmer so pls don't laugh at my coding but have done some C, C++, Fortran (Yes I'm an electrical engineer) in my days.  A number of things has stumped me abit and one of them was the use of arrays which didn't work for me too well.  I was to use the array for storing my parameters of each size.  Another one that really got me puzzled was the use of the docRef = activeDocument object.  The docRef.height and docRef.width will tell you the dimensions of the document based on the units set for rules.  I set mine for pixels.  The problem I had was the statement if(docRef.height > docRef.width) { do some stufff}.  If I change the  > to < for the same document it alway gives me a "true" logical.  After some thoughts today, I suspect that true is anything not 0 and false is only 0.  I will try this out tonight.  This theory does not fit well with my understanding on how the if statement works in other languages.  Any comments on this would be appreciated.
Oh and I noticed some extra code var declarations that is not needed such as the activeHistoryState - was determining if I need to use this or the perferences.rulerunits to restore my ruler perferences and apparently the activeHistoryState does not and forgot to remove from the code.

Similar Messages

  • I play games that require I use the back arrow a lot and have been getting the mesage that says this server is rerouting in such a way that it will never complete. How do I fix this, have tried clearing cookies cache etc..

    Play zynga games and use the back arrow all the time, continuously using this doesnt seem to go well with firefox 4...firefox3.6 no problems. I get a none responsive page off and on and sometimes have to switch between firefox and chrome. The message is that the server is rerouting in such a way as it will never complete, suggestions have been to clear cookies etc which doesnt fix the problem.

    This can be caused by corrupted cookies or cookies that are blocked (check the permissions on the about:permissions page).
    *https://support.mozilla.org/kb/fix-login-issues-on-websites-require-passwords
    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    *http://kb.mozillazine.org/Cookies
    *https://support.mozilla.org/kb/Deleting+cookies

  • How do I install itunes on a windows 8 computer. I keep getting the message that the app cannot run on my computer.

    I cannot install itunes on my windows 8 computer. I get the message that the app cannot run on my computer.

    Hi mlheidt,
    If you are having trouble installing iTunes on your Windows 8 computer you may want to use the following article to help you get it up and running -
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • I'm running Firefox 3.6.23. I get the message that HP Smart Web Printing is not compatible.

    I'm running Firefox 3.6.23 under Windows 7 64 bit. I want to use the HP Smart Web Printing program but under the add-ons I get the message that it is not compatible with this version. What ver. should I be running for compatibility? I saw at one time the icon on the toolbar but it went away after the next reboot. Help.
    Ray
    This question was solved.
    View Solution.

    It is listed as compatible with Internet Explorer versions 6, 7, and 8 .
    Best regards,
    erico
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • Just updated my iphone. Now I can se I have two? iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first

    Just updated my iphone. Now I can se I have two! iCloud accounts? One of them appears on my phone, and I have forgotten the password. When I try to add the other account, I get the message that this account is already added, but with the name of the first account where there is no available password. I have tried several times to reset the password, bun I don't get the information I need - I have no access to email. What can I do?

    Hi, thanks for the suggestion. I have tried as you suggested, and when opening the "purchased" apps some have the icloud logo next to them, but I only have "OPEN" against "Find My iPhone". When opening it up, it goes through the same routine; needs to be updated before proceeding, and wouldn't update because I don't have IOS8.
    Anything else I could try, or am I doomed!
    All of your help is much appreciated, thanks

  • I am running an Apple imac G-5 with OS 10.5.8. I am getting the message that my version of Safari is no longer working. I downloaded a newer version of Safari and I got the message that it would not work with my OS 10.5.8. Does any one have a suggest

    I am running an Apple imac G-5 with OS 10.5.8. Processor: 2 GHz. Memory: 2 GB DDR SDRAM.  I am getting the message that my version of Safari is no longer working. I downloaded a newer version of Safari and I got the message that it would not work with my OS 10.5.8. Does any one have a suggest

    Your post somehow found its way to a little-viewed forum for an obsolete Apple productivity program. I have asked the Hosts to move you to a more active and appropriate forum for your product.

  • I have a 4g touch. I updated ibook in itunes and now, every time I sync, I get the message that the app won't run in os6. Is there any way I can revert the app in itunes so I have the latest version that will work with OS6?

    I recently updated ibook in my Itunes.  Now, every time I sync, I get the message that it won't update the ipod as ibook won't run in OS6. Is there any way I can revert the ibook app in itunes so it quits trying to install the current ibook app. I am trying to stop getting the warning message. I am also concerned if I ever have to reinstall the app.

    Delete the app from the iTunes library on your computer and then transfer the version from iPod to computer by:
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer

  • I am running ver 9.0.1, but I keep getting the message that I am not running the latest version? Why? and how can I get rid of this message?

    On my firefox start up screen, I get the message that I am not running the latest. It asks that I upgrade now. However, under "about firefox," I am running 9.01, the latest version. I'd like to know why I'm getting this message and how I can get rid of it.
    Thank you.

    Hi jerzyguitar,
    You may see that message below the Google search box on www.google.com/firefox which is the old Firefox default home page. That page is no longer being maintained by Google.
    You should try changing your home page to:
    about:home
    If you don't know how to change the home page, you should take a look at the Knowledge Base article [[How to set the home page]].
    Hopefully this helps

  • TS3276 Accessing Gmail suddenly stopped working on both my Powerbook pro running latest OS and Mail versions and on my iPhone. I can access via the web. I get the error that my password or username is incorrect. I reset my password in Gmail and confirmed

    Accessing Gmail suddenly stopped working on both my Powerbook pro running latest OS and Mail versions and on my iPhone. I can access via the web. I get the error that my password or username is incorrect. I reset my password in Gmail and confirmed it works on gmail, I then changed it on my Iphone and Mac Mail. It still does not work. I deleted the gamil account on mail on my mac and reinstalled it and it still will not work

    I too started having my password rejected in MAIL.app for imap.mail.me.com for my icloud email address.  Can login to icloud with web browser fine.  This has been happening off and on for several days.....if I wait 2-3 hours it will suddenly start working again, but then problem re-asserts itself ;-)

  • HT201320 When I set up my aol account on my iPhone 5, I get the message that I cannot get mail because my user name or password for aol is incorrect.

    I just upgraded to iPhone 5 and every time I try to.add my aol email account, I get the message that my username or password is incorrect so I can't get mail.  Does anyone know how to fix this?

    Go here, do this:
    http://www.google.com/accounts/DisplayUnlockCaptcha
    See if that fixes things.

  • HT201320 I keep getting the message that my user name or password is not correct.

    I am attempting to add a new email account to my phone.  I had the account, but it got deleted by accident. 
    Now I cannot get it set up because I keep getting the message that the username/password is incorrect.
    It is NOT. 
    Help

    If you have two-step verification turned on in your email account, you'll have to log in with a browser and turn it off.

  • I'm wanting to use the "Actions" in Photoshop Elements 11.  But when I get the Actions box up, it is only showing a small list of effects to use.  And no side bar to go any further.  When I click on the little arrow at top and then click on "load actions"

    I'm wanting to use the "Actions" in Photoshop Elements 11. But when I get the actions box up, it is only showing a small list of effects to use. And no side bar. So I can't go any further.  When I click on the little arrow at top and click on "load actions", I am only getting a box with empty space saying "No items match your search".  The folder at the top does say "Actions".  How do I get more effects?  The tutorials that I've checked into all show a long list of effects in their box.  Can anyone help? 

    To use the existing actions, try the following:
    1. Open one of the Action Sets, in this example Special Effects is the Action Set, by pressing the small arrow beside the set name.
    2. Then click on the name of the Action, in this example Faded Ink is the Action name.
    3. Then press the Play button to run the action.

  • I keep getting the message that my start up disc is almost full, what can I do?

    I keep getting the message that my start up disc is almost full. What can I do?

    Empty the Trash if you haven't already done so. If you use iPhoto, empty its internal Trash first:
    iPhoto ▹ Empty Trash
    Do the same in other applications, such as Aperture, that have an internal Trash feature. Then restart the computer. That will temporarily free up some space.
    According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation. You also need enough space left over to allow for growth of the data. There is little or no performance advantage to having more available space than the minimum Apple recommends. Available storage space that you'll never use is wasted space.
    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.
    You can more effectively use a tool such as OmniDiskSweeper (ODS) or GrandPerspective (GP) to explore the volume and find out what's taking up the space. You can also delete files with it, but don't do that unless you're sure that you know what you're deleting and that all data is safely backed up. That means you have multiple backups, not just one. Note that ODS only works with OS X 10.8 or later. If you're running an older OS version, use GP.
    Deleting files inside an iPhoto or Aperture library will corrupt the library. Any changes to a photo library must be made from within the application that created it. The same goes for Mail files.
    Proceed further only if the problem isn't solved by the above steps.
    ODS or GP can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To see everything, you have to run it as root.
    Back up all data now.
    If you have more than one user account, make sure you're logged in as an administrator. The administrator account is the one that was created automatically when you first set up the computer.
    Install the app you downloaded in the Applications folder as usual. Quit it if it's running.
    Triple-click anywhere in the corresponding line of text below on this page to select it, then copy the selected text to the Clipboard by pressing the key combination command-C:
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    sudo /Applications/GrandPerspective.app/Contents/MacOS/GrandPerspective
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window by pressing command-V. You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning to be careful. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The application window will open, eventually showing all files in all folders, sorted by size. It may take a few minutes for the app to finish scanning.
    I don't recommend that you make a habit of doing this. Don't delete anything as root. If something needs to be deleted, make sure you know what it is and how it got there, and then delete it by other, safer, means. When in doubt, leave it alone or ask for guidance.
    When you're done with the app, quit it and also quit Terminal.

  • TS1702 I have an iPhone 4 it won't let me download any apps I keep getting the message that my device has no memory left and I do have 1.9G left what wrong i

    I have an iPhone 4 it won't let me download any apps I keep getting the message that my device has no memory left and I do have 1.9G left what's wrong as far as I know everything is up to date on the phone it is running slow please help thanx!

    I figured out what was going on the app had miss represented how much space it would take it had said it was 1.2g's however it was really 1.9g's which was all I had left on the phone I downloaded it to my computer first from the apps store then was able to see this. At that point I was able to rearrange some memory to accomadate it's size thanx for the help.
    Mick

  • Why can't I open iTune Store on my PC?   When I click on the iTunes Store box, I get the message that the iTunes Store has stopped working.  This happens everytime.  What is wrong with my download?

    My PC is running Windows 7.  I have downloaded the new OS Version for iTunes onto the computer.  It all works fine from the iPod Touch, but when I click the block for the iTunes Store, I get the message that "iTunes has stopped working".  What is wrong? How can I fix it so I can purchase from the store on my PC instead of having to use the small keyboard on the iPod Touch?

    There's an issue currently that a lot of us are experiencing in that we all get the error message "iTunes is currently unavailable; please try later"
    It's an issue with Apple and we're awaiting an update re this
    I've posted a topic in regards to this after having a long conversation with Apple support this morning and will be receiving a call from their tech team tomorrow to run through it further
    As it stands iTunes cannot be accessed via ATV's and nor can it be streamed via AirPlay from iTunes to the ATV
    However I can access all films/iCloud content via my Mac Mini with no issues!

Maybe you are looking for

  • Print quality in Aperture 3 and layout export

    I searched, but did not find recent information on print quality of books ordered through Aperture 3. So, my questions are: 1. How is the quality of the books ordered through Aperture 3? Few years ago I heard that the pictures are a bit darken. Is th

  • Select-options for time stamp

    Any ideas on which data element to be used for select-options for timestamp on the screen so that a user is able to f4 help too. i am using data element 'tzntstmps' but i am not getting f4 help for it.

  • TMOBILE NO CONTRACT PHONES

    I have a question. Why does Best Buy sell the same phone as T-Mobile but for less? It should be that T-mobile sells the phone for less and Best Buy sells it for more money. Example: Nokia Lumia 521 Best Buy 99.99  Nokia Lumia 521 T-Mobile 126.00 prov

  • Searching word docs with verity - strange problem

    I am searching word documents using cfsearch. These documents are basically forms. Some of the fields such as name etc. are with back fill enable for user input. So if I search the names in this field with back fill I get 0 records. If it's a plain t

  • Initial Load Setup...Potential Big Problem

    Hi All, I think we have a big problem.  I have posted a similiar question before, but answers are confusing to me.  Let me explain our current situation and please comment. 1. We are loading billing documents, thus using VDITM. 2. We have 2 number ra