i am trying to execute photoshop javascript by clicking button. when i enter the complete path of that javascript file then its working fine. however, when i create package and tried on other machine then it wont work.
now i am trying to run it via path to me but its not working. i have tried following:
tell application id “com.adobe.photoshop”
do javascript file log(path to me as text & “Contents:Resources:myscript.jsx”)
You’ve got lots of mistakes in there…The parent property should be class “NSObject”, sender has one n, no space between mainBundle and (), you’re missing " after the app identifier. Are you copying and pasting or retyping?
OK, it looks like a bug in my earlier code too. Get rid of the property mainBundle; you don’t want a property named after a method. The next line then says"mainBundle’s pathForResource_ofType_", when it should say “theBundle’s pathForResource_ofType_”. And it looks like the “do javascript” command is a bit fussy, so you need to give it both the word file and the HFS path. So:
on ButtonClicked_(sender)
set theBundle to current application's NSBundle's mainBundle()
set thePath to theBundle's pathForResource_ofType_("myscript", "jsx") as text
set theHFSPath to (thePath as POSIX file) as text
tell application id "com.adobe.photoshop"
do javascript file theHFSPath
end tell
end ButtonClicked_
i can run more then one script, however, when i click on the button then it initialize photoshop cs6. i have two photoshop installed that is cs4 and cs6. previously it wasnt happening. however, when i use “set thePath” then it populate cs6 every time i click on button.
set theBundle to current application’s NSBundle’s mainBundle()
set thePath to theBundle’s pathForResource_ofType_(“FirstPreferences”, “jsx”) as text
set theBundle to current application's NSBundle's mainBundle()
set thePath1 to theBundle's pathForResource_ofType_("LightenPhoto", "jsx") as text
set theBundle to current application's NSBundle's mainBundle()
set thePath2 to theBundle's pathForResource_ofType_("LastPreferences", "jsx") as text
tell application id "com.adobe.photoshop"
set theHFSPath to (thePath as POSIX file) as text
do javascript file theHFSPath
set theHFSPath to (thePath1 as POSIX file) as text
do javascript file theHFSPath
set theHFSPath to (thePath2 as POSIX file) as text
do javascript file theHFSPath
end tell
Every time when i run this script through button, it initializes Photoshop CS6. Even Photoshop CS4 is Opened.
First, you only need the line “set theBundle to current application’s NSBundle’s mainBundle()” once.
The problem of multiple files is really an old AppleScript problem. The only real solution is to use full path to the application:
set appPath to (path to applications folder as text) & "Adobe Photoshop CS6:Adobe Photoshop CS6.app"
using terms from application id "com.adobe.photoshop"
tell application appPath
...
But you may find the problem only occurs when developing your application. It might be easier to develop it with CS6 anyhow.
You can’t. If you want to use whatever version the user has, you can’t control which version is started. When you want to develop it, quit all versions first – when you open your project, it will open the default copy. Use the id as you did earlier, and develop in the default value.
This is not really an AS or ASObjC problem – it’s just the way to OS works.