initialize photoshop

hi,

i am developing an app which runs photoshop in background. while running an app, i want to check whether photshop is open, if not then open it and copy one file to photoshop folder.

any idea???

Hi,

In plain AppleScript this checks whether an application is running


if application "Adobe Photoshop CS3" is not running then
	-- do something
end if

But the first

tell application "Adobe Photoshop CS3"

block launches Photoshop anyway

Not since 10.5, and the introduction of application objects. There are a couple of samples in the release notes.

thanks shane and stefan,

if i want to create application compatible with cs2,cs3,cs4,cs5, is there any way that if the application is not opened then dialog box will appear to open the same…

thanks

You can get the name of the installed Photoshop version with this ASOC code


set photoshopPath to current application's NSWorkspace's sharedWorkspace's absolutePathForAppBundleWithIdentifier_("com.adobe.Photoshop")
 set installedPhotoShopApp to photoshopPath's lastPathComponent()
    

Instead of specifying the application by name it’s also possible to use the bundle identifier


tell application id "com.adobe.photoshop"

thanks a ton stefan…

one more thing, is it possible that when user run my application and if the photoshop is not open he will get a message to open photoshop

you can do it this way automatically


if application id "com.adobe.photoshop" is not running then
	launch application id "com.adobe.photoshop"
end if

thanks stefan,

its not opening photoshop.

i have placed this script in my main appdelegate file that is

on applicationWillFinishLaunching_(aNotification)

if application id “com.adobe.photoshop” is not running then

launch application id “com.adobe.photoshop”

end if

end applicationWillFinishLaunching_

anyhtnig wrong?

on my machine it works fine.
I have CS3. Maybe Adobe has changed the name of the bundle identifier in later versions

how to find the right bundle identifier

while PS is running


tell application "System Events" to set bundleIdentifier to bundle identifier of (1st process whose name contains "photoshop")
display dialog bundleIdentifier

PS: this is the Cocoa way to check for an running application and launch it if necessary


set runningPhotoShops to current application's NSRunningApplication's runningApplicationsWithBundleIdentifier_("com.adobe.Photoshop")
        if runningPhotoShops's |count|() as integer = 0 then
            current application's NSWorkspace's sharedWorkspace's launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.adobe.Photoshop", current application's NSWorkspaceLaunchDefault, missing value, missing value)
        end if

hi stefan,

i am scripting photoshop with the xcode interface. i want to make it compatible for all the version of photoshop. currently i have photoshop cs4 installed. therefore, i have to right tell application “Adobe Photoshop CS4” otherwise it gives error. how to rectify it, please suggest.

thanks

try it like in post #7

thanks stefan it worked…

you have made my day…

one more thing… is it possible to copy a file from project to photoshop system folder… becoz i need to copy color paper file to photoshop folder so that my photoshop action can use that file.

pls suggest.

thanks again

Of course it’s possible.

You can use the Finder, the shell cp command or copyItemAtPath_toPath_error_() method of NSFileManager.

I have no idea what photoshop system folder means but consider that the name of the Photoshop folder in /Applications depends on the version number

thank you stefan,

i just want to move one file from path “” to other path “”

can u pls explain bit more…

it will be of great help

move or copy, this is a difference.
Something like this:


set success to current application's NSFileManager's defaultManager's copyItemAtPath_toPath_error_("/source/path", "/destination/path", missing value) as boolean
if not success then
     -- do some error handling
end

hi stefan,

thank you for your reply.

i want to copy this file during installation of my application, so this script will do?

move : moveItemAtPath_toPath_error_()
copy : copyItemAtPath_toPath_error_()