Re: CENTER window on Screen
Re: CENTER window on Screen
- Subject: Re: CENTER window on Screen
- From: Michelle Steiner <email@hidden>
- Date: Thu, 17 Oct 2002 18:27:45 -0700
On Thursday, October 17, 2002, at 05:00 PM, Thierry Lavallie wrote:
I'd like to center a window (whatever size it is) to the user screen
(whatever size it is).
Could anyone tell me the syntax I should use?
It depends on whether the application has commands for that.
Here's an example using the Finder. I don't know how to determine the
resolution of the monitor, nor the height of the menu bar, so I've hard
coded values (using my 600 by 800 monitor, and guessing the height of
the menu bar)
-- 600 by 800 monitor
set monitor_width to 800
set monitor_height to 600
--height of the menu bar
set menu_bar_height to 22
tell application "Finder"
activate
try
set the front_window to the front window
on error
display dialog "there is no open window."
end try
set window_bounds to the bounds of the front_window
set window_width to (item 3 of window_bounds) - (item 1 of
window_bounds)
set window_height to (item 4 of window_bounds) - (item 2 of
window_bounds)
set window_left to (monitor_width - (window_width)) / 2
set window_right to window_left + window_width
set window_top to (monitor_height - (window_height)) / 2 +
menu_bar_height
set window_bottom to window_top + window_height
set the bounds of the front_window to {window_left, window_top,
window_right, window_bottom}
end tell
--Michelle
We're not human beings having a spiritual experience.
We're spiritual beings having a human experience.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.