• 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: Swap foreground and background windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Swap foreground and background windows


  • Subject: RE: Swap foreground and background windows
  • From: Steven Audette <email@hidden>
  • Date: Sun, 24 May 2009 15:45:17 -0600

You almost had it, you want the action "AXRaise" to bring a window forward.  This doesn't actually swap the windows positions in the list of ordered windows, it just brings the back most window to the front and pushes the other windows back like a stack of cards:

tell application "System Events"
set myApp to first application process whose name is "TextEdit"
-- If you are running from a Script launcher like FastScripts, you might want something like this...
-- set myApp to first application process whose frontmost is true


-- This creates a filterd list of windows that ignores floating windows and minimized windows
set myWindows to (every window whose (subrole is "AXStandardWindow" and value of attribute "AXMinimized" is false)) of myApp


-- We need at least two windows to swap
if (count of myWindows) < 2 then
beep
return
end if


-- The magic that gets the back most window to the front
perform action "AXRaise" of last item of myWindows
end tell
 _______________________________________________
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: Swap foreground and background windows
      • From: Quark67 <email@hidden>
  • Prev by Date: Re: Swap foreground and background windows
  • Next by Date: Re: Swap foreground and background windows
  • Previous by thread: Re: Swap foreground and background windows
  • Next by thread: Re: Swap foreground and background windows
  • Index(es):
    • Date
    • Thread