Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Applescript to run javascript

Explorer ,
May 08, 2013 May 08, 2013

Hi all,

I got error in this script. Could anyone help on this?

tell application "Finder"

    activate

    set myApps to {"CS3", "CS4", "CS5"}

    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"

    if the result is not false then

        set myApp to "Adobe InDesign " & selectedApp

        display dialog myApp

        set myFile to "Applications:" & myApp & ":Scripts:Scripts Panel:Sample.jsx"

       

        tell my application myApp

            activate

            run script file myFile   // error "Adobe InDesign CS4 got an error: A unknown token can’t go after this “)”." number -2740

        end tell

    end if

end tell

Regards

Suresh

TOPICS
Scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , May 09, 2013 May 09, 2013

Hi,

you're right. The script does not compile. I don't know the reason, perhaps Shane reads the thread and knows the answer. Macscripter.net may be a good point for posting this.

A workaround: Create the whole ID-Tellblock as string and do a vanilla run script command.

tell application "Finder"

    activate

    set myApps to {"CS3", "CS4", "CS5.5"}

    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"

    if the result is not false then

       

...
Translate
Advisor ,
May 08, 2013 May 08, 2013

hey suresh..

can't realy remember the last time i used applescript, but still here are my two cents:

the javascript you are trying to run has a error somwhere in it. open it in estk and try a "Check Syntax" (form the edit menu)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2013 May 08, 2013

Hi Vamitul,

Thanks for your quick response. I  checked the javascript in ESTK which shows no error.

Even if I write a simple javascript (an alert message), applescript throw an error in the same line.

Regards

Suresh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 08, 2013 May 08, 2013

ok...

tell application "Finder"

    activate

    set myApps to {"CS3", "CS4", "CS5"}

    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"

    if the result is not false then

        set myApp to "Adobe InDesign " & selectedApp

        display dialog myApp

        set myFile to "Applications:" & myApp & ":Scripts:Scripts Panel:Sample.jsx"

        set myScript to POSIX path of myFile

      

        tell my application myApp

            activate

            run script file myScript

        end tell

    end if

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2013 May 08, 2013

Hi Vamitul,

Thanks for showing a different way to specify the path. It  throw an error in same line like this.

run script file myScript // error "Adobe InDesign CS4 got an error: Can’t make some data into the expected type." number -1700 to item

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 08, 2013 May 08, 2013

aa.. it's do script, not run script. (just checking form the scripting guide) try:

do script alias myScript language javascript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2013 May 08, 2013

Hi Vamitul,

It works fine when I edit the  script like this:

tell application "Finder"

    activate

    set myApps to {"CS3", "CS4", "CS5"}

    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"

    if the result is not false then

        set myApp to "Adobe InDesign " & selectedApp

        display dialog myApp

        set myFile to "Applications:" & myApp & ":Scripts:Scripts Panel:Sample.jsx"

        --set myScript to POSIX path of myFile

        tell application "Adobe InDesign CS4"

            activate

            do script alias myFile language javascript

        end tell

    end if

end tell

But how could I run to selected Application.

Regards

Suresh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 08, 2013 May 08, 2013

tell application myApp

     activate

     do script alias myFile language javascript

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 08, 2013 May 08, 2013

Hi Mark

Thanks for your reply. But it shows an error at this line

do script alias myFile language javascript

Reference.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 09, 2013 May 09, 2013

Hi,

you're right. The script does not compile. I don't know the reason, perhaps Shane reads the thread and knows the answer. Macscripter.net may be a good point for posting this.

A workaround: Create the whole ID-Tellblock as string and do a vanilla run script command.

tell application "Finder"

    activate

    set myApps to {"CS3", "CS4", "CS5.5"}

    set selectedApp to choose from list myApps with prompt "Choose Application:" with title "Launch Application"

    if the result is not false then

        set myApp to "Adobe InDesign " & selectedApp

        set myFile to "Applications:" & myApp & ":Scripts:Scripts Panel:Sample.jsx"

    end if

end tell

set myString to "tell application " & "\"" & myApp & "\"" & return ¬

    & "do script alias " & "\"" & myFile & "\"" & " language javascript" & return ¬

    & "end tell"

run script myString

It runs here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2013 May 09, 2013
LATEST

Hi hans

Thankyou. This works fine for me.

Thanks for everyone those who given me your suggestion.

Regards

Suresh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines