Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 40 lines (29 sloc) 1.086 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
-- AUTHOR: Geoffrey Grosenbach http://peepcode.com
-- DESCRIPTION: Show the coordinates of a window of fixed size, centered.

set windowWidth to 1000
set windowHeight to 600

set AppleScript's text item delimiters to "x"

set res to "" & windowWidth & "x" & windowHeight

if res is "" then
display dialog "You need to enter a correct response"
return
end if
set {windowWidth, windowHeight} to text items of res

set AppleScript's text item delimiters to ""

-- Works with most setups
tell application "Finder"
set {screen_top, screen_left, screen_width, screen_height} to bounds of window of desktop
end tell

tell application "System Events"
set myFrontMost to name of first item of (processes whose frontmost is true)
end tell

tell application "Finder"
set {desktopTop, desktopLeft, desktopRight, desktopBottom} to bounds of desktop
end tell

set {w, h} to {0, 0}

tell application "System Events"
display dialog "X " & ((screen_width - windowWidth - w) / 2) & "
Y " & (((screen_height - windowHeight) / 2.0) - desktopTop) & "
W " & windowWidth & "
H " & windowHeight
end tell
Something went wrong with that request. Please try again.