AppleScript via JavaScript (doScript in Photoshop)

Hi everyone,
I was looking for a way to execute AS from JS to bind my AS on hotkey.
I found a thread with this code in there:
// JavaScript
var myscr = new File('/C/1/book/my.vbs');
if (myscr.exists) {
app.doScript(myscr, ScriptLanguage.visualBasic)
do I thought that I'll create a .jsx file with this code and it'll work
var myscr = new File('/Users/macintosh/Documents/Adobe Scripts/enter.applescript');
if (myscr.exists) {
app.doScript(myscr, applescriptLanguage)
but it didn't
I fought that the problem is that doScript is from inDesign/Illustrator and tried doAction but it seems it's only for Actions.
Please explain me what am I doing wrong?
Kind regards, Sergey

Take a look at the documentation each of Adobe's apps differs in its scripted commands. ID has 'do script' in given language (the best of the bunch) Photoshop will let AppleScript & Visual Basic do JavaScript. Illustrator is like Photoshop except you can pass an arguments array to the command…
File.execute(); did NOT work with my quick test the calling JavaScript:
#target photoshop
var appleScript = new File('~/Desktop/Test.app');
if (appleScript.exists) appleScript.execute();
The AppleScript compiled and saved as 'Application' in on run statement…
on run
tell application "Adobe Photoshop CS2"
activate
if exists document 1 then
set Doc_Ref to current document
tell Doc_Ref
set Doc_Name to name
display alert "Testing" message ¬
Doc_Name giving up after 2
end tell
else
display alert "Script Error" message ¬
"No document is open." as warning giving up after 2
end if
end tell
end run

Similar Messages

  • Uploading a File with AppleScript via JavaScript

    Hi everybody,
    being new to AppleScripting and JavaScripting I'm faced with the following problem:
    Is it possible to make AppleScript to input the path for a file to be uploaded via JavaScript? If yes, what should be the correct Path Format and how to wrap it up the JavaScript action into AppleScript? I've tried a few comands but to no success.
    On the webpage in question, there's a "Choose" button, that is defined as follows:
    <input type=​"file" class=​"gwt-FileUpload" name=​"swfFile">​
    I've been trying to use the following syntax:
    do JavaScript "document.getElementsByName('swfFile')[0].value('Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf')" in document 1
    as well as this one, where the Path is definitelly understood by shellscript:
    do JavaScript "document.getElementsByName('swfFile')[0].value('/Users/myaccount/Desktop/Scrap book/!动画.swf')" in document 1
    The name of the file is (and must remain) in chinese, but for testing purposes I have also tried files with english names, without success.
    Currently I'm using a solution with JavaScript comand:
    do JavaScript "document.getElementsByName('swfFile')[0].click()" in document 1
    to click the finder  window to browse for the file, and manipulating  keystrokes by using System Events to find the right file, but it's not  infallible with a number of files and it's hardly an ellegant sollution.
    Any idea what I'm doing wrong?
    Cheers!

    @twtwtw
    the do JavaScript "document.forms[0].submit()" command didn't work, so I kept the original way of submitting by clicking the button. The submitting part works, but not the input file part.
    That's the code I used
        tell application "Safari"
            do JavaScript "document.getElementById('gwt-uid-13').value='on'" in document 1
            do JavaScript "document.forms[0].elements['swfFile'].value=" & "'" & SWFFilePath & "'" in document 1
            do JavaScript "document.getElementsByClassName('gwt-SubmitButton')[0].click()" in document 1  
            delay 1
        end tell
    with SWFFilePath set as the POSIX path as well as the default file format
    Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf'
    but it did not work.
    If you've got the time, feel free to upload an .swf. The service is free and the server delats uploaded files after 15 min. (if you don't have any, you may try an empty .txt file instead - it won't get converted, but the point is just to get it into the input box).
    In the meantime, I'll have a look at adayzdone's suggestion. It's not perfect (the downside being that it requires the window to be active, so I can't run the script in the background or with my screensaver & password on), but it's still more reliable than my sollution with navigating arrowkeyes.

  • Resize an Object via javascript

    Resize an Object via javascript
    How do I...
    I want to select an object in my document, onscreen, (an image, or text) then run a script that will discern the object selected, and show a dialog box that will allow me to input a sizing percentage for that object (with anchor corner/center)(Press enter and object resizes).

    No they don't.
    Acrobat may be bundled with Creative Suite collections but the APIs has nothing in common other than the use of JavaScript. CS apps use the ExtendScript system, Acrobat has its own internal API and an SDK for inter-application control.
    PDF is an end-destination format - the page content is not designed to be edited, so while there are tools in the user interface to allow touchups and corrections to page objects those features are not available for automation. The JavaScript engine does not have access to the low-level document structure, it can only see markup (comments and form elements) and a limited range of document properties.
    bdmasha wrote:
    They are all part of a suite of tools that share a common access to internal api's via scripting/programming languages.
    InDesign is not Photoshop is not Illustrator, but they have much in common when accessing their api's that Acrobat does not allow--and Acrobat is part of that Adobe suite.
    Thanks again.

  • Retreiving the content created with the Note Tool via Javascript??

    Hey guys, is it possible to retrieve the text content created with the Note Tool from the tool palette  in a photoshop document via Javascript? Basically, I wanted to store some text inside the Photoshop psd document, and then later on I can use scripting to access the content to be use as variables.
    I have search the Javascript scripting reference pdf and the forum here, and I can't find any info the Note Tool. Much appreciated.

    Ok, so I am using the activeDocument.info.keywords property to store my text content. The content is basically a chunk of text that contains some parameters that the user can modify to save out a document. In my script, I am using a variable to store the content from the info.keywords property. But my next hurdle is how can I extract specific part of that variable into other variables, like storing the C:\projects\Textures\ into another variable? I've done some research and got a sense that the "match" method in javascript along with the use of regular expressions might do the job. But I am stuck. Any suggestions?
    info.keywords property has the follow chunk of text:
    // file path to save 
    path(C:\projects\Textures\)  
    // save file format (psd or tga, etc)
    format (tga) 
    // include a single alpha channel with the file y/n 
    alpha(n) 
    // alpha name - default should be "alpha1" 
    alphaName(alpha1) 
    // scale from the original size 
    scale(.5) 
    //sharpening
    sharpen(.5)
    script code:
    var saveDoc = activeDocument.info.keywords;
    var savePath = saveDoc[0].match(regular expression goes here); // how to grab C:\projects\Textures\ from the saveDoc variable???
    alert(savePath);

  • Converting simple AppleScript to JavaScript

    Hello to all,
    I need to convert a simple AppleScript to JavaScript, but as I don't know one bit about JavaScript, is there anyone willing to help me out ?
    Here is the AppleScript:
    tell application "Adobe Photoshop CS5"
         activate
              set display dialogs to never
              set thisdoc to current document
              tell thisdoc
                        resize image resolution 300 resample method none
              end tell
    end tell
    Very simple script to resize some low-res pictures without touching final resolution.
    Thanks !

    This will change the resolution only..
    app.displayDialogs = DialogModes.NO;
    activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

  • Translation AppleScript to JavaScript

    Hi all,
    I need a translation from AppleScript to JavaScript.
    tell application "Adobe Illustrator"
    activate
    do script "Neigen" from "Prepress" without dialogs
    end tell
    Can anybody help?
    Thanks a lot.
    Sabine

    If all you want to do via Applescript is chain several 'Actions' to run in a certain order then just duplicate the action line and change the name strings to those of the other action & action sets like so…
    tell application "Adobe Illustrator"
    activate
    do script "Neigen" from "Prepress" without dialogs
    do script "Action A" from "Set A" without dialogs
    do script "Action B" from "Set B" without dialogs
    end tell
    Both the names strings of the actions & the action sets are case sensitive…

  • I have recently updated the new apps via creative cloud now photoshop and bridge no longer work, they open then say they have encountered a problem and close, I also tried opening the old version of photo shop but getting the same result

    I have recently updated the new apps via creative cloud now photoshop and bridge no longer work, they open then say they have encountered a problem and close, I also tried opening the old version of photo shop but getting the same result

    What OS version? What's the exact error? Exactly when does the error occur? What previous versions? What is on the screen when the error displays? Does Photoshop get fully open?
    Try opening Photoshop holding down Shift key immediately to turn off plug-ins. Lots of good suggestions here: Photoshop: Basic Troubleshooting steps to fix most issues

  • How to get elements in a multi-value field via javascript?

    The following will set variables.variable1 to variables.variable2 when the "Script Link" component is clicked...
    <Field>
    <Display class='Javascript'>
    <String>
    function myScript() {
    el=getElement(document.mainform,"variables.variable1");
    el2=getElement(document.mainform,"variables.variable2");
    el.value=el2.value;
    </String>
    </Display>
    </Field>
    <Field name='Script Link'>
    <Display class='Link'>
    <Property name='URL'>
    <String>javascript:myScript();submitCommand(document.mainform,%20'Recalculate');</String>
    </Property>
    </Display>
    </Field>
    My issue is, if variables.variabl2 is a list / multivalued, i get errors trying to traverse through the "array".
    How can i read and set an a list element via javascript function above? I've tried things like get() , and variables.variable2[0] .
    any help would be appreciated....
    is there an API somewhere i can reference?

    Hi,
    thanks for your reply!
    If I have the parameters in the URL and use the method GET it works all right.
    but I need the method to be POST. I suppose, I have the wrong way identifying the parameter name
    This is from VB
    varTarget = "http://localhost:9090/gm/getData" ' getData is my servlet
    xmlSendStr = "SQLStmt=SELECT TCPD_Cars.* From TCPD_Cars WHERE (((TCPD_Cars.CarIdent)=45));"
        xmlHttp.Open "POST", varTarget, True   'True means asynchronous
        xmlHttp.Send xmlSendStrthis is part of my Servlet
         protected void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter writer  = response.getWriter();
              String SQLStmt = request.getParameter("SQLStmt") ;
            //make the database query and get the returns
            writer.println(GetSQLData(SQLStmt));
            //close the write
            writer.close();                    
         }I would appreciate any suggestions

  • Firefox 3.6 crashes or hangs when setting an iframe src to a pdf via javascript. 3.5 works fine

    Firefox hangs or crashes when setting iframe src to a pdf via javascript. Works fine in all previous versions of Firefox. This is using the most recent version of Adobe Reader 9.
    == This happened ==
    Every time Firefox opened
    == I upgraded to Firefox 3.6

    More info:
    Seems to be the same issue as this
    [http://support.mozilla.com/en-US/forum/1/585926#threadId622326]
    and this
    [http://support.mozilla.com/en-US/forum/1/585926?forumId=1&comments_threshold=0&comments_parentId=585926&comments_offset=20&comments_per_page=20&thread_style=commentStyle_plain#threadId659555]

  • Flash inserted via Javascript not working in IE.

    I am having issues viewing flash that has been inserted via
    javascript in Internet Explorer. I had to uninstall my flash about
    a week ago. I've since reinstalled flash and reinstalled flash
    player for all my browsers. All flash shows where it hasn't been
    inserted via javascript (ie. youtube.com) but javascript flash is
    not showing at all in IE. Firefox is working fine. Any help in
    resolving this issue for IE would be greatly appreciated.
    Duncan

    I'm having the same exact problem. I've uninstalled,
    reinstalled, the works. Flash works great in my alternate browser,
    Opera, but not with IE.

  • How can I add a watermark via JavaScript that includes the current datestamp?

    Part of my daily work process here is to scan in a huge stack of inbound mail. I then OCR the scans, delete the blank pages, and add a watermark. I've got a batch process set up for the first two steps, but I can't make a watermark for the datestamp itself and need to do so via JavaScript, but I have a luddite-level understanding of it.
    As of right now, these are my settings I'm using to add the datestamp:
    What I want to do is run a script to do the same thing and insert the current date where I have mm-dd-yy currently, but I don't have the first clue of where to start. Any help you could offer would be hugely appreciated

    You can use the doc.addWatermarkFromText() method as a JavaScript step in an Action.
    for example
    var dt = new Date();
    var stoday = (dt.getMonth() + 1) + '-' + dt.getDate() + '-' + dt.getFullYear();
    this.addWatermarkFromText({
    cText: "Deposit\r" + stoday,
    nTextAlign: app.constants.align.right,
    nHorizAlign: app.constants.align.right,
    nVertAlign: app.constants.align.top,
    nHorizValue: -72, nVertValue: -72
    See the SDK Help files for information on what all the parameters do.

  • Firefox 4.0 support for printing embedded PDF files in iFrames via JavaScript

    I recently upgraded to Firefox 4.0 and can no longer print embedded PDF documents contained in an iFrame.
    My company's web application has several pages which load PDF files from a Servlet into an iFrame. The pages in question all have "Print" buttons which when clicked executes a JavaScript function to obtain reference to the iframe containing the PDF, place it into focus() (e.g., frames['pdfdoc'].focus();), and invoke print() (e.g., frames['pdfdoc'].print();). There are no errors, or exceptions caught when the JavaScript function is invoked, but the "Print" button is no longer operational.
    Does Firefox 4.0 no longer support iFrames? The issue goes away if I revert back to ver 3.6.16

    I have same issue for printing embedded PDF files in iFrames via JavaScript in Firefox 5.0.
    In previous versions it was working fine. But not in Firefox 4.0/5.0.
    Is there any solution for this problem?

  • Apply watermark and then apply Flattener Preview via JavaScript

    Hello all,
    I have a bunch of PDF files which were generated from InDesign.
    Currently I am applying a watermark to all the PDFs in Acrobat XI and then a flattener preview to all of the PDFs manually one PDF at a time.
    I want to make a script which does all this.
    I also tried the Action panel, but it didn't automate the flattener preview part.
    I am comfortable with JavaScript and scripting in general.
    Any help or a pointer to resources will be appreciated.
    Thanks and regards.

    Thanks for replying.
    The flattener preview is located under "Print Production" panel. Where one can configure the text flattening options, among many other settings.
    I want to flatten the text (convert it to outlines) via JavaScript as you have suggested.
    Please suggest any sample code.
    Thanks and regards.

  • Stop player via javascript.

    I am opening a flash player into a floating div. Works almost
    perfect, except that when I close the div, the movie contines to
    play. I can hear it even though I cannot see it. Is there a way to
    stop the movie from playing via javascript when I click on the
    div's "close" button?

    hello there
    look for ExternalInterface class on flash's documentation.
    basicly it allows you to define functions in JS that call
    functions inside flash and vise versa

  • Problem obtaining BitmapData for a canvas via Javascript

    Hi,
    For my web application I have one HTML button, which is outside of flash application shown on the same page. Via Flex application I've declared callback function to be called by Javascript in this way:
    ExternalInterface.addCallback("cbProcessButton", processButton);
    For HTML button I have this:
    <input id="bSave" name="button" type="submit" value="Save" onclick="getSWF('${application}').cbProcessButton();" />
    And inital lines of processButton function (which is Flex function) are defined as this:
              var bitmapData:BitmapData = new BitmapData(canvas.width, canvas.height, false, 0xFFFFFF);
              bitmapData.draw(canvas);
              var jpgEncoder:JPEGEncoder = new JPEGEncoder(85);
              var jpgStream:ByteArray = jpgEncoder.encode(bitmapData);
    Now I have problem here. If I call that processButton in this way for my canvas via Javascript - then I get length of jpgStream as 32654 bytes and after save into a file - that jpg file cannot be shown properly.
    But if I call the same processButton via a Flex button, which is placed inside my Flex - I get jpgStream in my case of length 33074 bytes and after save to a file - could normally show it later.
    I'm using Flex Builder 3 with Flex sdk 3.5.0.12683 installed and later show everything/work via Flash Player v10,1,53,64 installed on WinXP.
    Is it known bug/limitation of BitmapData usage in such Javascript scenario? Or is it bad sdk/Flash Player? Are you able to reproduce such in your environment?
    I'm really going out of my mind to understand why lengths of encoded data in 2 cases are different. Of course I know about that 2176 Error for other situations dealing with Flex UI, but here I don't get it - so I assume my Javascript scenario is allowed by Adobe so far.
    Any help would be highly appreciated.
    Andrejus

    Thanks very much, Everybody. Here is something that works. This is based on all the inputs provided by you guys. Many thanks.
    <table>
    <td width="3%" align=right></td>
    <td align=left valign=top> <b>Existing Notes:</td>
    <TD><textarea name="existing" wrap="hard" cols="70" rows="10" onkeypress
    ="validateSize(this, 2000)" onchange="validateSize(this, 2000)" READONLY>
    <%
    int logSize = actionLog.size();
    if (logSize > 0) {
    for (int j=logSize-1; j >=0; j--){
    DealStatusAction dsa = (DealStatusAction)actionLog.get(j);
    String actionNm = dsa.getActionName();
    String actionDate = dsa.getActionDate().toString() + "";
    String memo = dsa.getMemo();
    String actionPerformer = ((dsa.getLastName() == null || dsa.get
    FirstName() ==null)?"":(dsa.getFirstName() + " " + dsa.getLastName()));
    String datePerf = actionDate + " " + actionPerformer;
    %>
    <%=datePerf%>
    <%=actionNm%>
    <%=memo%>
    <%
    %>
    </textarea>
    </TD>
    </table>

Maybe you are looking for

  • Vendor assignment for multiple line tiems

    All, We are with SRM 5.0, Classic Scenario. I have created SC with 2 line items and given different vendors for two line items of the same SC. It should generate two POs for this, right ? Bt, only one Purchase Req. and PO is created and showing in R/

  • E-1 restoring sms saved in memory card by backup f...

    Dear Sir, yesterday at 4 pm i put my phone on silent mode and when i again had a look at it at 6 pm all my sms stored in Inbox, sent items, folders and drafts were missing. they were all stored in memory card and NOT n phone memory. memory card is wo

  • Issue with Query Designer

    Hi Guys, I am using 3.5 query designer.i have a requirement in a report.There is keyfigure structure developed which has key figures defined for eg Actual,target etc.This structure is is been restricted as whole by posting period ie 1,2,3 &4.so all t

  • How to display af:commandImageLink in accessibility mode

    We use af:commandImageLink, and works all right. However, it does not show up in accessibility mode. Is it possible to display af:commandImageLink in accessibility mode?

  • 3 gigs worth it for gaming?

    This may be a dumb question but I gotta ask before any purchase: Will 3 GB (as opposed to 2 GB) of memory make a significant difference for gaming? That is, once the Radeon/GeForce's 256 MB of video memory is used up, will that system memory be utili