Hello all!
I am somewhat new to applecripting, but I was wondering if there was a way to create a script to watch or check if a certain application has been launched.
Reason:
I want to create an application add-on so to speak that will launch if another specified application is launched.
I don’t see what’s not very nice about the idle handler. It hardly takes up cpu usage (depending on what it does), and can be made to run in the background just like any background process.
global is_running
on run
set is_running to false
end run
on idle
tell application “System Events”
if exists process “iCal” then
set is_running to true
else
set is_running to false
end if
end tell
if is_running then
beep 1
– do whatever
end if
return 2 – checks every 2 seconds
end idle
I haven’t tried the addition I mentioned, but I think they might listen to notifications which would be a more elegant solution. But you are right - there is nothing wrong with an on idle handler.