• 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
Isn't there a way...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Isn't there a way...


  • Subject: Isn't there a way...
  • From: Glenn Sugden <email@hidden>
  • Date: Sun, 27 Jul 2003 15:08:35 -0500

...to write a generic-ish 'center front window' script? I understand that
the application has to be scriptable, but when running the script (from
Script Menu), the front windows seems to (often) be taken out of focus...
When running from a script editor, it works fine...

Thanks in advance!

::Glenn

---

tell application "System Events"
set front_app_name to name of front process whose visible is true and
frontmost is true
end tell
tell application front_app_name
set screen_list to screen list starting with main screen
set main_screen to item 1 of screen_list
set main_screen_bounds to bounds of main_screen
set main_screen_width to (item 3 of main_screen_bounds) - (item 1 of
main_screen_bounds)
set main_screen_height to (item 4 of main_screen_bounds) - (item 2 of
main_screen_bounds)
set window_bounds to bounds of 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 x to (main_screen_width - window_width) / 2
set y to (main_screen_height - window_height) / 2
set bounds of front window to {x, y, x + window_width, y +
window_height}
end tell
_______________________________________________
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.

  • Follow-Ups:
    • Re: Isn't there a way...
      • From: John Delacour <email@hidden>
References: 
 >Re: 'mount volume' for Windows volumes (From: mglm3 <email@hidden>)

  • Prev by Date: Re: terminal works, do shell script doesn't
  • Next by Date: Re: Sorting A List - Need Help
  • Previous by thread: Re: 'mount volume' for Windows volumes
  • Next by thread: Re: Isn't there a way...
  • Index(es):
    • Date
    • Thread