1/2 way there. This would need to be placed somewhere where it would automatically be running and get application events.
-- Basics for pausing and resuming an application (Safari) ala AppleScript.
-- need to wrap in detectors triggered when the application becomes active and when it moves to the back to auto pause and resume.
-- Alex Zavatone 2012
--
property pPID : 0
on run
set pPID to GetSafariPID()
end run
on GetSafariPID()
set myShellString to "ps -Ac"
-- set myResult to every paragraph of (do shell script myShellString) whose (word 4 is "Safari")
set myResultList to paragraphs of (do shell script myShellString)
-- set myParas to paragraphs of myResult where (word 4 = "Safari")
repeat with myItem in myResultList
set myCondition to (word 4 of myItem = "Safari")
if myCondition then
set myPID to word 1 of myItem
exit repeat
end if
end repeat
return myPID
end GetSafariPID
on PauseSafari()
set myShellString to "kill -SIGSTOP " & pPID
do shell script myShellString
end PauseSafari
on ResumeSafari()
set myShellString to "kill -SIGCONT " & pPID
do shell script myShellString
end ResumeSafari