PDA

View Full Version : Using 'Get' command in Applescript


Jason
2010-08-08, 15:13
Hi there,

I'm trying to get an application to open a highlighted/selected file and then open it. The file is not the same every time so I cannot define it in the script.
Where am I going wrong?

get selectedFile
tell application "Adobe Photoshop CS3"
activate
end tell

Regards

chucker
2010-08-08, 15:26
I'm confused. Is the file selected in Finder? If so, how are you invoking the script? Or would you like the script to prompt the user for a file to choose?

If it's selected in Finder, try something like this:

tell application "Finder"
set theFile to the selection as alias
end tell

tell application "Adobe Photoshop CS3"
activate
open theFile
end tell

If you wish the user to choose a file, that would be:

set theFile to choose file

tell application "Adobe Photoshop CS3"
activate
open theFile
end tell

These scripts were both tested, albeit with Preview, not Photoshop.

Jason
2010-08-08, 15:27
Sorry. That was a bit vague. The file is already selected in the finder. Then invoke it through Launchbar or something similar.

Regards

chucker
2010-08-08, 15:33
I've amended my post with working code.

Jason
2010-08-08, 15:35
Chucker, thanks so much. I really appreciate it! :)