• 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: moving window using window title
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: moving window using window title


  • Subject: Re: moving window using window title
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 15 Aug 2012 22:12:34 -0500

On Aug 14, 2012, at 22:06, Bob Cuilla <email@hidden> wrote:
I have several windows on the desktop which i would like to arrange occasionally .  i am looking for the syntax to move a window to a specific location using the title in the title bar
______________________________________________________________________

Hey Bob,

Do you mean in the Finder?

Here's how to get the bounds of the front window:

----------------------------------------------------------------------
on frontFinderWindowBounds()
tell application "Finder"
try
(bounds of front window) / 0
on error winBounds
end try
set AppleScript's text item delimiters to {"{", "}"}
set winBounds to "{" & text item 2 of winBounds & "}"
set the clipboard to winBounds
end tell
end frontFinderWindowBounds
----------------------------------------------------------------------

Here's how to move the window:

----------------------------------------------------------------------
set documentsFolderTarget to alias "Ryoko:Users:chris:Documents:"

tell application "Finder"
set winName to "Documents"
tell window winName
if (its target as alias) = documentsFolderTarget then
set bounds to {0, 44, 870, 520}
# Set more attributes if desired.
end if
end tell
end tell
----------------------------------------------------------------------

It's not really necessary to check the window-target unless your environment may have more than one window with the same name and a different target, and of course the script above can be simplified further.

Here's a way to set multiple windows.  I've used the continuation character in the list of records to make it easier to read, but of course it's not necessary to do this.

----------------------------------------------------------------------
set winPositions to {¬
{winName:"Documents", winBounds:{0, 44, 870, 520}}, ¬
{winName:"Downloads", winBounds:{871, 44, 1741, 520}}}

tell application "Finder"
repeat with listIndex in winPositions
tell window (winName of listIndex)
set bounds to winBounds of listIndex
end tell
end repeat
end tell
----------------------------------------------------------------------

--
Best Regards,
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

References: 
 >moving window using window title (From: Bob Cuilla <email@hidden>)

  • Prev by Date: Re: Mailing list errors?
  • Next by Date: Re: OS X 10.8 Security & Applescripts - "unidentified developer"
  • Previous by thread: moving window using window title
  • Next by thread: Re: moving window using window title
  • Index(es):
    • Date
    • Thread