Thursday, July 24, 2014

#1 2013-01-30 06:26:34 am

claudiotrope
Member
Registered: 2013-01-30
Posts: 1

Killing/Quitting programs when screensaver starts

When Googling around I didn't find a script for this exactly, but was able to piece one together from other hints on this forum and elsewhere, so wanted to share the solution in case anyone else looks.

From the AppleScript Editor save as an Application with the "stay open" option, then make sure you launch and check the "Open At Login" option from the dock.

You can just insert more if-then blocks if you want to kill more applications. I just often leave Skype running when I don't intend to, so that is the code you see.

As shown, the script only checks every 5 minutes, which is precise enough for me. Obviously, you can reduce that number, at the cost of the script waking up more frequently and using some CPU cycles.

Applescript:


-- Script to quit certain applications when ScreenSaver is active
--

on ApplicationIsRunning(appName)
   tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
   return appNameIsRunning
end ApplicationIsRunning

on idle
   -- check if screen saver and Skype are running
   if ApplicationIsRunning("Skype") and ApplicationIsRunning("ScreenSaverEngine") then
       tell application "Skype" to quit
   end if
   -- don't check for another 5 minutes (converted to seconds)
   return 300
end idle


Filed under: quit, kill, screensaver

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.052 seconds, 11 queries executed ]

RSS (new topics) RSS (active topics)