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
|