If you really want to get professional, you can use launchd.
Make your self this script and save it in your documents:
-- /Users/yourusername/Documents/relaunchDaemon.scpt
on run {appName}
tell application "System Events" to set alreadyActive to (exists process appName)
if alreadyActive is true then
quit application appName
else
activate application appName
end if
return 0
end run
Than make yourself a property list file with the following contents:
And save it in “/Users/yourusername/Library/LaunchAgents/com.ief2.relaunchdaemon.plist” after you’ve made sure the path to the script is correct.
Wow, thanks for all your helpful advice! I truly appreciate it.
I have another question though… I really only need it to cycle 1 time. I intend to save the script as an application and run it on the hour using iCal.
Launch app
Wait 10
Quit app
Wait 10
Launch app
(then quit the script all together, leaving “mongo” running until iCal launches the applesciript app again)
I really don’t know how to modify your scripting language to accomplish this (im sorry, I thought it would be much more basic).
any additional help you might offer would be most warmly appreciated.
I’m not sure wether this will work, that is, if iCal is active the moment that the script is run, I can’t get you back any further. If however iCal is not active, then this should activate the previous frontmost application.
And It would be better to run it as a script, hopefully you can do that from iCal.
set frontApp to getFrontApp()
tell application "Mongo" to activate
delay 10
tell application frontApp to activate
on getFrontApp() -- Regulus6633/Hank and Nigel Garvey
set colon to ":" as Unicode text
set dot to "." as Unicode text
set appPath to (path to frontmost application as Unicode text)
considering case
if (appPath ends with colon) then
set n to -2
else
set n to -1
end if
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to colon
set appname to text item n of appPath
if (appname contains dot) then
set AppleScript's text item delimiters to dot
set appname to text 1 thru text item -2 of appname
end if
set AppleScript's text item delimiters to astid
end considering
return appname
end getFrontApp