Convert applescript to javascript

I have a file which contains applescript. I need to convert this script to javascript  and run it in my windows. Please help!!!

Muppet Mark seems right.
Translating APS to JS is someway doable. Unless the APS script uses cmd that don't have matching items in JS, it shouldn't be a problem.
However, I don't think a script may convert  all by itself an APS script to JS.
For generic commands such as "set x to" or "display dialog", it's quite easy but how to translate "whose", "starts", "first", "last"....?
What if the script goes for file on the system using a tell application "Finder" block ?
In my opinion, the translation process can only be efficiently done by a someone knowing both languages.
Can I help you ?
Loic

Similar Messages

  • Converting Simple Indesign AppleScript to Javascript

    Hi,
    I have been using as imple Indesign AppleScript but need to convert it to javascript and have no prior experience.  I've been reading the Adobe pdf about scripting and it is great as it shows the differences between the 3 (as, js, vb) but I'm still having trouble figuring out how this would conver.  Would anyone be able to show me the converted result?
    AppleScript:
    tell application "Adobe InDesign CS5.5"
         tell every document
              set visible of layer "Interactive - Web" to true
              set visible of layer "Interactive - Print" to false
         end tell
    end tell
    Javascript:
    var myDocuments = app.documents.everyItem(); // something like this?
    It hides/shows the visibility of 2 specific layers for all opened documents.  I pretty much need to hide/show 2 specific layers ina  book and this should/can accomplish that.
    Thanks for any help!

    This should work:
    var documentsArray = app.documents.everyItem().getElements();
    for (var i = 0; i < documentsArray.length; i++) {
              var document = documentsArray[i];
              var layers = document.layers;
              layers.itemByName("Interactive - Web").visible = true;
              layers.itemByName("Interactive - Print").visible = false;
    Also, it might be possible to do this without using "getElements" which "resolves the object specifier", eliminating the need for the "for" loop. Something like this:
    app.documents.everyItem().layers.itemByName("Interactive - Web").visible = true;
    app.documents.everyItem().layers.itemByName("Interactive - Print").visible = false;

  • 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);

  • 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.

  • Applescript to Javascript

    I have an Applescript that I need to convert it into  Javascript.
    To create Indesign instancs in applescript i use
    tell application "Adobe InDesign CS5" statement
    How create Indesign instancs in JavaScript
    or what is equivelent statement of ( tell application "Adobe InDesign CS5" ) in Java Script
    Using COM I create Indesign Instance like
    #include "indesign.h"
    INDESIGN::_Application oApplication;   
    if(oApplication.CreateDispatch(L"InDesign.Application") ==0)
        AfxMessageBox(L"Dispatch is not created");
    How create Indesign instance using java Script ?
    Thanks.

    Thanks CarlosCanto for reply
    I am a new developer and want to create indesign application.
    First I explane you, What i want to do?
    I want to create an Indesign application for both mac and window os.
    First I use COM and crate indesign application
    #include "indesign.h"
    INDESIGN::_Application oApplication;   
    if(oApplication.CreateDispatch(L"InDesign.Application") ==0)
         // Dispatch is not created;
    But COM is not supported on mac so i want to use JavaScript
    I am using Qt to develop my application and i want to create a java script .
    When I run my JavaScript on window  then Indesign application should start .
    In my post I write about ExtendScript ToolKit 3.6, but i do not want to use this tool.
    For example on mac in Apple Script when i run my apple script
    tell application "Adobe InDesign CS5.5"
    set myDocument to make document with properties
    end tell
    in apple script editor which is inbuild with mac, Indesign Application start(create) sucessfully.
    I want to use javaScript editor inbuild with window.
    Like in applescript there is no need to put the script in  /Users/<username>/Library/Preferences
    /Adobe InDesign/Version 7.5/<locale>/Scripts
    Simply when i run apple script application create. I want to such using java script.
    I do not want to put my script C:\Documents and Settings\<username>\Application Data
    \Adobe\InDesign\Version 7.0\<locale>\Scripts      
    to start indesign application
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/In DesignScripting/InDesign-ScriptingTutorial.pdf
    Establish communication with the InDesign application object:
    AppleScript :   tell application "Adobe InDesign CS5"
    VBScript     :    Set myInDesign = CreateObject("InDesign.Application")
    JavaScript   :    Refer to the application as app.
    plz give a simple java script (.js) file example which create Indesign Application (instance) , when i run my java script in any java script editor, No need to put script /Users/<username>/Library/Preferences/Adobe InDesign/Version 7.5/<locale>/Scripts and run script after run indesign.
    Like in VB to create indesign object we use CreateObject("InDesign.Application"). In javascript how create object of InDesign Application.
    Thanks

  • 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…

  • Is there a way to trigger batch process via Applescript or Javascript?

    Based on what I've found so far on the internet, the answer is no. The Applescripts I've found so far that attempt to run a batch process don't work for me in either Acrobat Pro 8 or Pro 9.
    I've been using Applescript to automate a process that starts in InDesign (create PDFs), then goes to Acrobat to set open options (I've got a batch process for that but can't find a way to trigger it). If I can get that to work, I'll attempt to automate the task of using a Photoshop droplet to create JPEGs of a specific size from these PDFs.
    I've settled on InDesign CS3 for creating single-page PDFs from a multiple-page document, partly because I could not find a scriptable way to do this in Acrobat. I know just enough about Applescript to be dangerous. I know much less about Javascript.
    Any help would be appreciated.
    Thanks,
    Kevin Stauffer

    Kevin some thing like this for Photoshop should aid you
    set Todays_Date to do shell script "date \"+%d-%m-%y\""
    -- Create new folder to save to
    tell application "Finder"
    set Raster_Images to make new folder at desktop with properties ¬
    {name:"Rasterized PDF's " & Todays_Date}
    end tell
    -- Set Photoshop settings
    tell application "Adobe Photoshop CS2"
    activate
    set display dialogs to never
    set User_Rulers to ruler units of settings
    set ruler units of settings to pixel units
    -- set background color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:0}
    -- set foreground color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:100}
    end tell
    -- Get list of PDF's
    set The_Question to "Do you want to include all the subfolders" & return & "within your folder selection?"
    set The_Dialog to display dialog The_Question buttons {"No", "Yes"} default button 1 with icon note
    if button returned of The_Dialog is "Yes" then
    set Input_Folder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
    tell application "Finder"
    set File_List to (files of entire contents of Input_Folder whose name extension is "pdf")
    end tell
    else
    tell application "Finder"
    set Input_Folder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
    set File_List to (files of Input_Folder whose name extension is "pdf")
    end tell
    end if
    set File_Count to count of File_List
    if File_Count = 0 then
    display dialog "This folder contains no PDF files to rasterize!" giving up after 2
    end if
    -- Loop through the files in list
    repeat with This_File in File_List
    tell application "Finder"
    set The_File to This_File as alias
    end tell
    -- Tiger (OSX.4) shell call to count the pages
    set Page_Count to my PDF_Pages(POSIX path of The_File)
    if the result is not false then
    -- Loop Photoshop through the page count
    repeat with i from 1 to Page_Count
    tell application "Adobe Photoshop CS2"
    activate
    open The_File as PDF with options ¬
    {class:PDF open options, bits per channel:eight, constrain proportions:true, crop page:trim box, mode:CMYK, page:i, resolution:300, suppress warnings:true, use antialias:true, use page number:true}
    set Doc_Ref to the current document
    tell Doc_Ref
    flatten
    -- Enter your name strings into two enties below
    -- Case sensitive stings
    -- do action "My Action" from "My Action Set"
    -- New file naming options
    set Doc_Name to name
    set ASTID to AppleScript's text item delimiters
    set AppleScript's text item delimiters to " "
    set Doc_Name to text items of Doc_Name
    set AppleScript's text item delimiters to "_"
    set Doc_Name to Doc_Name as string
    set AppleScript's text item delimiters to "-"
    set Doc_Name to text item 1 of Doc_Name
    set AppleScript's text item delimiters to ASTID
    if Page_Count = 1 then
    set New_File_Name to (Raster_Images as string) & Doc_Name & ".tif"
    else
    set File_Number to ""
    repeat until (length of (File_Number as text)) = (length of (Page_Count as text))
    if File_Number = "" then
    set File_Number to i
    else
    set File_Number to "0" & File_Number
    end if
    end repeat
    set New_File_Name to (Raster_Images as string) & Doc_Name & "_" & File_Number & ".tif"
    end if
    end tell
    save Doc_Ref in file New_File_Name as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false}
    close current document without saving
    end tell
    end repeat
    end if
    end repeat
    -- Set ruler units back to user prefs
    tell application "Adobe Photoshop CS2"
    set ruler units of settings to User_Rulers
    end tell
    beep 3
    -- OSX Tiger shell handler
    on PDF_Pages(This_PDF)
    try
    do shell script "/usr/bin/mdls -name kMDItemNumberOfPages" & space & quoted form of This_PDF & " | /usr/bin/grep -o '[0-9]\\+$'"
    on error Error_Message number Error_Number
    if Error_Number is 1 then
    display alert "Page Count Unavailable" message "The page count for " & This_PDF & " is unavailable." giving up after 3
    return false
    else
    display alert "Error " & Error_Number message Error_Message giving up after 3
    return false
    end if
    end try
    end PDF_Pages
    and something like this to perform JavaScript from within AppleScript for Acrobat
    You would be better talking to the JavaScript Experts on how to use addScript() to get your doc level scripts in.
    property Default_Path : (path to desktop folder as Unicode text) as alias
    property JavaScript : "var re = /.*\\/|\\.pdf$/ig; var filename = this.path.replace(re,''); try { for (var i = 0; i < this.numPages; i++) this.extractPages( { nStart: i, cPath: filename+'_' + (i+1) +'.pdf' }); } catch (e) { console.println('Aborted: '+e) }" as text
    set The_PDF to choose file default location Default_Path ¬
    with prompt "Where is the multi-page PDF?" without invisibles
    tell application "Adobe Acrobat 7.0 Professional"
    activate
    open The_PDF
    tell active doc
    do script JavaScript
    close saving yes
    end tell
    end tell

  • Convert pdf by javascript

    Is it possible to use Acrobat to convert a web page (this web page with js http://funpage.it ) into a PDF and  retain some of the basic javascript functionality that previously  existed on the webpage?  Ie. Hide/Show of fields when a link is  clicked.  I'd like to be able to do this without taking any special  steps toward making the script compatible with acrobat if at all  possible.

    No. Converting a web-page to a PDF is basically printing it to a PDF
    printer. All interactive components will be lost.

  • 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

  • Converting Actionscript to Javascript

    When I think of the Cappucino framework. It converts Objective-J to pure Javascript in the browser no plugin required because the compiler itself is in Javascript.
    I am thinking, why dosen't Adobe do the same with Actionscript?
    Is this something feasable?

    I've spoken to a few people who think that an "Export to HTML(5)" option in Flash Pro would be awesome.  I have no idea how something like that would work, or if it is even possible.
    The Flex Framework relies heavily on Flash Player APIs.  I suspect there are not standard 'JavaScript' parallels for many if those APIs.

  • Converting formcalc to javascript.

    Hi there,  I would like to know if i can convert an existing formcalc script to javascript and if so how can it be done?

    The only way I know is "manually", means you have to write the scripts by yourself in the desired language.

  • How to use AppleScript, Safari, JavaScript, and jQuery together

    Hello to all,
    I am running AppleScript to populate some forms on various websites, but to activate some behaviors on the various forms that I can't activate with Safari and JavaScript I think I might need jQuery. Only problem is that I don't really know how to get the functions of jQuery embedded into a running AppleScript.
    Would any of you knowledgeable people know how to accomplish this.
    Any help would be welcome.
    Thank you,
    Chris

    Yes I did get to that part.... I went trough external to retrive itunes folder... When I selected the folder, it said that it was locked, choose another folder... I then went to my external again to my itunes folder and and used command I to see if folder was locked and it wasn't.... it was suggested on another forum to reboot.. which I did and still same problem... All I want to do is link my external hard drive that has my itunes playlist from another Mac to my new one.. and to also use the external as the main source for adding new songs to my playlist...

  • Execute applescript from javascript

    I am trying to execute an AppleScript .app from my webpage. Is it possible?

    I am trying to execute an AppleScript .app from my webpage. Is it possible?
    I suspect not. Javascript is supposed to prevent the program from messing with you local environment.  Could be some control to allow it.  I wouldn't want some random web page invoking an Applescript that messes with my file system.
    You need activex on a windows machine. Microsoft is happy to like you download any random program and run it on your Windows box.  I do not run Windows.

  • AppleScript do javascript

    So I noticed that the
    do javascript <path to script file>
    I have used in versions 7-CS4 causes an error now.
    "General Photoshop error occurred. This functionality may not be available in this version of Photoshop."
    However adding "file"
    do javascript file <path to script file>
    allows it to work again.
    Does anyone have a copy of PS7 that they could test this with to see if this form is backwards compatible? I can confirm that it works with CS3.

    Blah nevermind - pretend I never asked this question....

  • Applescript "do javascript" click link

    Hi, I want to make a script that opens a web page in Safari, then clicks on a link. however the link is javascript, with a self referrential href
    Does this code look like it should be working, becuse it jsut gives a blank page.
    on run
    launch application "Safari"
    tell application "Safari"
    make new document at end of documents
    set URL of document 1 to "http://www.biggercity.com/chat"
    do JavaScript "bcStartCamsOnly()" in document 1
    (*actual link is *)
    end tell
    end run

    Blah nevermind - pretend I never asked this question....

Maybe you are looking for

  • Not able to execute startEclipse.bat file in Eclipse (Oracle utilities SDK)

    In Eclipse installation, i am not able to run "startEclipse.bat" file in this path "C:\SPLSDK\SDK\shortcuts" which comes under Oracle Utilities Software Development Kit 4.0.0. once i start installing startEclipse.bat, i get a error message "windows c

  • Why cant i facetime on my iphone 4

    I can not facetime on my i phone.  Doesnot have soundwhen sometime tries to facetime me only shows missed calles no sound when i try to facetime them

  • Connection Error in Enterprise Reporting Web

    When using Distributed Retrieve with Enterprise Reporting Web we are receiving the following HsComUI error: Unable to connect to server: Access to the server was denied Code 80040308 If the user clicks OK and tries to access again it will be successf

  • Field-Symbols as Method Parameter

    Hi all, is there a way to create a field symbol within a method and export this field-symbol directly as a method parameter? The problem is that we can't pass a field symbol as method parameter unless it's assigned, but we would like to assign the fi

  • Can't use three-finger double tap zoom.

    iPad 2 version 6.3.1. Couple of days ago, I tried to use the three-fingered, double-tap zoom, but it didn't work. Now, being a middle-aged person, I like to use this feature. So, tried again. Didn't work. Double tapped all over the screen. Nada. Went