• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Safari auto pause and resume script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Safari auto pause and resume script


  • Subject: Safari auto pause and resume script
  • From: Alex Zavatone <email@hidden>
  • Date: Thu, 26 Apr 2012 11:15:12 -0400

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Am I missing something here? I thought there was an elegant way to do this.
  • Next by Date: Re: Mailboxes in Mail & Applescript
  • Previous by thread: Re: Mailboxes in Mail & Applescript
  • Next by thread: Selecting From A List
  • Index(es):
    • Date
    • Thread