• 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
Re: Script to pause/suspend Safari when in the background and resume when in foreground
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script to pause/suspend Safari when in the background and resume when in foreground


  • Subject: Re: Script to pause/suspend Safari when in the background and resume when in foreground
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 03 Apr 2013 13:28:12 -0500

Hey Folks,

# A simple proof that it works:
tell application "System Events"
  set _flagA to frontmost of process "Script Debugger"
  set frontmost of process "Safari" to true
  set _flagB to frontmost of process "Safari"
  set _flagC to frontmost of process "Script Debugger"
  set frontmost of process "Script Debugger" to true
end tell

I prefer not to use System Events if at all possible, because it can hang for up to 2 seconds when it starts up cold on my machine.

This is quick and concise:

if (do shell script "ps -Ac | sed -En '/Safari$/p'") ≠ "" then
  tell application "Safari"
    if not frontmost then
      # Kill _javascript_
    end if
  end tell
end if

--
Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: Script to pause/suspend Safari when in the background and resume when in foreground
      • From: Alex Zavatone <email@hidden>
    • Re: Script to pause/suspend Safari when in the background and resume when in foreground
      • From: Alex Zavatone <email@hidden>
    • Re: Script to pause/suspend Safari when in the background and resume when in foreground
      • From: Alex Zavatone <email@hidden>
References: 
 >Safari (From: Alex Zavatone <email@hidden>)
 >Re: Safari (From: Luther Fuller <email@hidden>)
 >Re: Safari (From: 2551phil <email@hidden>)
 >Script to pause/suspend Safari when in the background and resume when in foreground (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Refresh Finder view?
  • Next by Date: Smile vs AppleScript Editor
  • Previous by thread: Script to pause/suspend Safari when in the background and resume when in foreground
  • Next by thread: Re: Script to pause/suspend Safari when in the background and resume when in foreground
  • Index(es):
    • Date
    • Thread