• 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: Luther Fuller <email@hidden>
  • Date: Mon, 25 May 2009 13:10:38 -0500

I have been following this thread, but not in detail, so I may have missed something. It's been nagging me, so I tried an experiment with TextEdit. Could I change the order of windows, specifically, could I move the front window to the back? Here's the script ...

tell application "TextEdit"
activate
set winList to (id of every window) as list
set newOrder to (rest of winList) & {item 1 of winList}


repeat with i from 1 to (count items of newOrder)
set winID to (item i of newOrder)
set index of window id winID to i
end repeat

end tell


The first thing I noticed was that it didn't work. The second thing I noticed was that the script does not change the currently active document window. When you manually change the order of windows, you click on a document window which brings it frontmost AND makes it the active window. (If you add this step manually, the script above does work.)

In order to make the script above work correctly, the last line needs to be added that makes the frontmost window active. Alas, I could find no such command in TextEdit's dictionary. So, I tried things that shouldn't work, but sometimes do.

tell application "TextEdit"
activate
set winList to (id of every window) as list
set newOrder to (rest of winList) & {item 1 of winList}


repeat with i from 1 to (count items of newOrder)
set winID to (item i of newOrder)
set index of window id winID to i
end repeat


set visible of window id (item 1 of newOrder) to false
set visible of window id (item 1 of newOrder) to true
end tell

Now it works! (But, will it help the current problem?)

 _______________________________________________
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>
References: 
 >Swap foreground and background windows (From: Quark67 <email@hidden>)

  • Prev by Date: TextEdit document format.
  • 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