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

AppleScript via JavaScript (doScript in Photoshop)

Contributor ,
Apr 23, 2010 Apr 23, 2010

Copy link to clipboard

Copied

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

http://sparklehorse.ru/ph/shit/Dock-20100423-234228.jpg

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

TOPICS
Actions and scripting

Views

3.3K

Translate

Translate

Report

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
Adobe
Adobe Employee ,
Apr 23, 2010 Apr 23, 2010

Copy link to clipboard

Copied

Try

myscr.execute()

Votes

Translate

Translate

Report

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
Contributor ,
Apr 24, 2010 Apr 24, 2010

Copy link to clipboard

Copied

Hi Tom, thanks for answer. It seems however that execute() launches AppleScript Editor instead of launching the script, similar for double click the file.

My research in Extendscript Editor dictionary showed that PS simply doesn't have doScript function InDesign has. This sucks.

Votes

Translate

Translate

Report

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
Guide ,
Apr 24, 2010 Apr 24, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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