As I was writing an AppleScript to control Skype and Adium yesterday, I wanted to make sure that I didn't start those applications if they weren't already running.
There seem to be a number of ways in AppleScript to check if an application is already running, and they all center around using the "
System Events
" method.Here's the one that I chose:
Read my previous blog entry for a description of the scripts that I wrote.tellapplication"System Events"if(count(everyprocesswhosenameis"Adium")) > 0thentellapplication"Adium"setmy status typetoawaysetmy status messageto"I'm on the phone..."endtellendif
if(count(everyprocesswhosenameis"Skype")) > 0thentellapplication"Skype"sendcommand"SET PROFILE MOOD_TEXT I'm on the phone..."script name"IM On Phone"----Uncomment the following if you'd like to take Skype off-line----sendcommand"SET USERSTATUS OFFLINE"script name"IM On Phone"endtellendifendtell
They are also available for download.
Thanks to sparrow from Walled Networks for pointing me in the right direction.
0 comments:
Post a Comment