Detecting status of application

Hi all,

I’m making a simple drag-and-drop applescript that will add icons and previews to photo files using GraphicConverter. The code is so short I might as well paste it below:


on open of finderObjects
	repeat with i in (finderObjects)
		set howdy to i as string
		tell application "GraphicConverter"
			create icon howdy with preview
		end tell
	end repeat
end open

It works great, but it leaves GraphicConverter open. Yes, it’s easy to close manually, but I would like the script to first see if it was open when the files were dragged, and if it was not open (ie: if the script opened the application), I want GraphicConverter to quit.

It’d be as simple as putting the “open” status of the application into a variable, but I can’t find any way to tell if an application is open or not.

Any ideas?

Thanks,
Dave

Does this work?

on open of finderObjects
	tell application "System Events" to set status_ to exists process "GraphicConverter"
	
	repeat with i in (finderObjects)
		set howdy to i as string
		tell application "GraphicConverter"
			create icon howdy with preview
		end tell
	end repeat
	
	if status_ is false then tell application "GraphicConverter" to quit
end open

– Rob

Rob,

That’s exactly what I was looking for. Thank you very much - works like a charm!

I’ve been using AppleScript for a little while now, but I’ve gotten away without learning much about System Events. Lately I’ve been seeing it pop up more and more in scripts that I’ve been interested in, so maybe it’s a good time to learn what I can.

Thanks again,
-Dave

Yep, it’s probably worth the time to at least become familiar with what System Events can and cannot do. :slight_smile:

– Rob