Passing Variable from Firefox Page to Applescript

On my PHP pages, I have data from a MySQL database that supplies path/filename info for some images. I would like to be able to click a button and open those images in PhotoShop. Every other solution I’ve tried stinks, so I thought I would give Applescript a try (never used it before). So I created an app in AS and wrote the Photoshop part. I have PHP set to call the Applescript app when a button is depressed. That part was easy and it’s working super.

What is a problem is getting the data from the PHP page to the Applescript. I thought I could do it in Javascript but I realized, reading here, that AS does not support the “do Javascript” statement for Firefox. Alas. :frowning: I searched and found an older thread on here that suggests writing a plug-in to do this, but that is totally beyond my capabilities. Is there any other alternative for what seems like a fairly simple task?

Thanks in advance for any help or guidance.

Applescript Editor 2.3
Photoshop 12.0.1

tell application "Adobe Photoshop CS5"
	set photo1 to "Macintosh HD:Applications:MAMP:htdocs:Collection:3:nav.gif"
	set photo2 to "Macintosh HD:Applications:MAMP:htdocs:Collection:3:pic1.jpg"
	set photo3 to "Macintosh HD:Applications:MAMP:htdocs:Collection:3:pic3.jpg"
		open file photo1
		open file photo2
		open file photo3
	on error
		display dialog "Couldn't locate all documents"
	end try
end tell

AppleScript: Applescript 2.1.2
Browser: Firefox 3.6.12
Operating System: Mac OS X (10.6)

Hi, Elizabeth. Welcome to MacScripter.

Not much help, I’m afraid, but it’s actually the other way round. Firefox lacks any support for AppleScript. Any chance of using Safari instead for the job? It’s scriptable and it has a ‘do JavaScript’ command. Last time I used it, the syntax was:

set js to "blah blah blah;"

tell application "Safari"
	set x to (do JavaScript js in front window)
end tell

But looking in the AppleScript dictionary for Safari 5.0.3, I see the ‘in’ parameter is now a tab. I’d guess that would be:

set js to "blah blah blah;"

tell application "Safari"
	set x to (do JavaScript js in current tab of front window)
end tell

Thank you, Nigel. I’ll drop Mozilla a note - can’t hurt. :slight_smile:

I’ll try Safari and the statements you suggest. The only problem is that there are some functions that were designed specifically with Firefox quirks in mind, and I am thinking that Safari may present some unanticipated results. None that are likely to be insurmountable, though.

Otherwise, I think I’m going to use Zeroclipboard’s Flash/javascript thingy to copy my PHP data (e.g., 3-1234-jpg) to the clipboard, and then let Applescript pick it up from there. I’m not real happy about this, because of all the wacky stuff that could end up on the clipboard by accident, but at least that’s a solution that I can deploy without much trouble.

Thanks again.