<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Centering Windows in Mac OS X with AppleScript</title>
	<atom:link href="http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/feed" rel="self" type="application/rss+xml" />
	<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript</link>
	<description></description>
	<lastBuildDate>Tue, 30 Aug 2011 04:38:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Lri</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17386</link>
		<dc:creator>Lri</dc:creator>
		<pubDate>Wed, 09 Mar 2011 14:01:45 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17386</guid>
		<description>I posted yet another version at the &lt;a href=&quot;http://apple.stackexchange.com/questions/9632/center-window-on-screen/9742#9742&quot; rel=&quot;nofollow&quot;&gt;apple.stackexchange thread&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>I posted yet another version at the <a href="http://apple.stackexchange.com/questions/9632/center-window-on-screen/9742#9742" rel="nofollow">apple.stackexchange thread</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Goodrick-Werner</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17385</link>
		<dc:creator>Andrew Goodrick-Werner</dc:creator>
		<pubDate>Mon, 07 Mar 2011 21:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17385</guid>
		<description>I&#039;ve updated my version of the script to take into account dock position and menu bar height — I also made sure to include your Terminal workaround, Tim. Enjoy! :)

tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot;
	tell dock preferences
		if screen edge is bottom then
			tell application &quot;System Events&quot; to tell process &quot;Dock&quot;
				set dockSize to size in list 1
				set dockHeight to item 2 of dockSize
				set screenHeight to (screenHeight - dockHeight)
			end tell
		else if screen edge is left then
			tell application &quot;System Events&quot; to tell process &quot;Dock&quot;
				set dockSize to size in list 1
				set dockHeight to item 1 of dockSize
				set screenWidth to (screenWidth + dockHeight)
			end tell
		else
			tell application &quot;System Events&quot; to tell process &quot;Dock&quot;
				set dockSize to size in list 1
				set dockHeight to item 1 of dockSize
				set screenWidth to (screenWidth - dockHeight)
			end tell
		end if
	end tell
	
	set screenHeight to (screenHeight + 22)
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize
		
		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt
		
		if myFrontMost is &quot;Terminal&quot; then
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}
		else
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}
		end if
		
		set the result to bounds of window 1
		
	end tell
end try</description>
		<content:encoded><![CDATA[<p>I&#8217;ve updated my version of the script to take into account dock position and menu bar height — I also made sure to include your Terminal workaround, Tim. Enjoy! <img src='http://static.incrementalism.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>tell application &#8220;Finder&#8221;<br />
	set screenSize to bounds of window of desktop<br />
	set screenWidth to item 3 of screenSize<br />
	set screenHeight to item 4 of screenSize<br />
end tell</p>
<p>tell application &#8220;System Events&#8221;<br />
	tell dock preferences<br />
		if screen edge is bottom then<br />
			tell application &#8220;System Events&#8221; to tell process &#8220;Dock&#8221;<br />
				set dockSize to size in list 1<br />
				set dockHeight to item 2 of dockSize<br />
				set screenHeight to (screenHeight &#8211; dockHeight)<br />
			end tell<br />
		else if screen edge is left then<br />
			tell application &#8220;System Events&#8221; to tell process &#8220;Dock&#8221;<br />
				set dockSize to size in list 1<br />
				set dockHeight to item 1 of dockSize<br />
				set screenWidth to (screenWidth + dockHeight)<br />
			end tell<br />
		else<br />
			tell application &#8220;System Events&#8221; to tell process &#8220;Dock&#8221;<br />
				set dockSize to size in list 1<br />
				set dockHeight to item 1 of dockSize<br />
				set screenWidth to (screenWidth &#8211; dockHeight)<br />
			end tell<br />
		end if<br />
	end tell</p>
<p>	set screenHeight to (screenHeight + 22)<br />
	set myFrontMost to name of first item of ¬<br />
		(processes whose frontmost is true)<br />
end tell</p>
<p>try<br />
	tell application myFrontMost<br />
		set windowSize to bounds of window 1<br />
		set windowXl to item 1 of windowSize<br />
		set windowYt to item 2 of windowSize<br />
		set windowXr to item 3 of windowSize<br />
		set windowYb to item 4 of windowSize</p>
<p>		set windowWidth to windowXr &#8211; windowXl<br />
		set windowHeight to windowYb &#8211; windowYt</p>
<p>		if myFrontMost is &#8220;Terminal&#8221; then<br />
			set bounds of window 1 to {¬<br />
				round ((screenWidth &#8211; windowWidth) / 2) rounding as taught in school, ¬<br />
				round ((screenHeight &#8211; windowHeight) / 2) rounding as taught in school, ¬<br />
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬<br />
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}<br />
		else<br />
			set bounds of window 1 to {¬<br />
				round ((screenWidth &#8211; windowWidth) / 2) rounding as taught in school, ¬<br />
				round ((screenHeight &#8211; windowHeight) / 2) rounding as taught in school, ¬<br />
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬<br />
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}<br />
		end if</p>
<p>		set the result to bounds of window 1</p>
<p>	end tell<br />
end try</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Moore</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17384</link>
		<dc:creator>Tim Moore</dc:creator>
		<pubDate>Mon, 07 Mar 2011 10:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17384</guid>
		<description>I found a &lt;a href=&quot;http://apple.stackexchange.com/questions/9632/center-window-on-screen&quot; rel=&quot;nofollow&quot;&gt;post on Stack Exchange&lt;/a&gt; that links to this post but asks about the issue with the Terminal. It&#039;s just a bug in Terminal&#039;s Apple Events support, but there is a workaround. Here it is:

[applescript]
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot;
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize
		
		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt
		
		if myFrontMost is &quot;Terminal&quot; then
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2 + windowHeight) rounding as taught in school}
		else
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}
		end if
		
		set the result to bounds of window 1
		
	end tell
end try
[/applescript]</description>
		<content:encoded><![CDATA[<p>I found a <a href="http://apple.stackexchange.com/questions/9632/center-window-on-screen" rel="nofollow">post on Stack Exchange</a> that links to this post but asks about the issue with the Terminal. It&#8217;s just a bug in Terminal&#8217;s Apple Events support, but there is a workaround. Here it is:</p>
<pre class="brush: applescript; title: ; notranslate">
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot;
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize

		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt

		if myFrontMost is &quot;Terminal&quot; then
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2 + windowHeight) rounding as taught in school}
		else
			set bounds of window 1 to {¬
				round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
				round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
				round ((screenHeight + windowHeight) / 2) rounding as taught in school}
		end if

		set the result to bounds of window 1

	end tell
end try
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Moore</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17355</link>
		<dc:creator>Tim Moore</dc:creator>
		<pubDate>Fri, 21 Jan 2011 22:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17355</guid>
		<description>Good tip, Andrew. Thanks!</description>
		<content:encoded><![CDATA[<p>Good tip, Andrew. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Goodrick-Werner</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17354</link>
		<dc:creator>Andrew Goodrick-Werner</dc:creator>
		<pubDate>Thu, 20 Jan 2011 05:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17354</guid>
		<description>Also, here&#039;s a tip I&#039;ve found to be extremely useful.

You can make this AppleScript a Service that is accessible from any application&#039;s menu in the Menu Bar. Open Automator, create a new Service — setting the options at the top to &quot;no input&quot; and &quot;any application&quot; — drag &quot;Run AppleScript&quot; into the workflow, and paste one of the scripts posted above into the text field. Save the Service, and run it from the Services menu in the Menu Bar.

I prefer this method to having the Scripts menu always visible in my menu bar, since this is the only AppleScript I use regularly.</description>
		<content:encoded><![CDATA[<p>Also, here&#8217;s a tip I&#8217;ve found to be extremely useful.</p>
<p>You can make this AppleScript a Service that is accessible from any application&#8217;s menu in the Menu Bar. Open Automator, create a new Service — setting the options at the top to &#8220;no input&#8221; and &#8220;any application&#8221; — drag &#8220;Run AppleScript&#8221; into the workflow, and paste one of the scripts posted above into the text field. Save the Service, and run it from the Services menu in the Menu Bar.</p>
<p>I prefer this method to having the Scripts menu always visible in my menu bar, since this is the only AppleScript I use regularly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axel</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17353</link>
		<dc:creator>Axel</dc:creator>
		<pubDate>Wed, 19 Jan 2011 17:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17353</guid>
		<description>Just wanted to say that this was incredibly helpful, as I&#039;m new to Macs and as obsessive-compulsive about placement as you are. Thanks!</description>
		<content:encoded><![CDATA[<p>Just wanted to say that this was incredibly helpful, as I&#8217;m new to Macs and as obsessive-compulsive about placement as you are. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Goodrick-Werner</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17007</link>
		<dc:creator>Andrew Goodrick-Werner</dc:creator>
		<pubDate>Mon, 15 Nov 2010 05:12:13 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17007</guid>
		<description>Again, thanks so much - I feel SO nice knowing that this is possible; I&#039;ve never even seen AppleScript until today!  I eventually figured out how your version worked, and came up with the following:

[applescript]
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot; to tell process &quot;Dock&quot;
	set dockSize to size in list 1
	set dockHeight to item 2 of dockSize
end tell

tell application &quot;System Events&quot;
	set screenHeight to (screenHeight - dockHeight)
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize
		
		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt
		
		set bounds of window 1 to {¬
			round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
			round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight + windowHeight) / 2) rounding as taught in school}
	end tell
end try
[/applescript]

The two problems with what I&#039;ve got are that Assistive Devices have to be enabled in System Preferences, and it&#039;ll only work with the Dock on the bottom, but I never move mine anyway.

Cheers!  :)</description>
		<content:encoded><![CDATA[<p>Again, thanks so much &#8211; I feel SO nice knowing that this is possible; I&#8217;ve never even seen AppleScript until today!  I eventually figured out how your version worked, and came up with the following:</p>
<pre class="brush: applescript; title: ; notranslate">
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot; to tell process &quot;Dock&quot;
	set dockSize to size in list 1
	set dockHeight to item 2 of dockSize
end tell

tell application &quot;System Events&quot;
	set screenHeight to (screenHeight - dockHeight)
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize

		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt

		set bounds of window 1 to {¬
			round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
			round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight + windowHeight) / 2) rounding as taught in school}
	end tell
end try
</pre>
<p>The two problems with what I&#8217;ve got are that Assistive Devices have to be enabled in System Preferences, and it&#8217;ll only work with the Dock on the bottom, but I never move mine anyway.</p>
<p>Cheers!  <img src='http://static.incrementalism.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Moore</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17005</link>
		<dc:creator>Tim Moore</dc:creator>
		<pubDate>Mon, 15 Nov 2010 03:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17005</guid>
		<description>Thanks!

It should be possible to make it center vertically using basically the same approach.

Try this:

[applescript]
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot;
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize
		
		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt
		
		set bounds of window 1 to {¬
			round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
			round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight + windowHeight) / 2) rounding as taught in school}
	end tell
end try
[/applescript]</description>
		<content:encoded><![CDATA[<p>Thanks!</p>
<p>It should be possible to make it center vertically using basically the same approach.</p>
<p>Try this:</p>
<pre class="brush: applescript; title: ; notranslate">
tell application &quot;Finder&quot;
	set screenSize to bounds of window of desktop
	set screenWidth to item 3 of screenSize
	set screenHeight to item 4 of screenSize
end tell

tell application &quot;System Events&quot;
	set myFrontMost to name of first item of ¬
		(processes whose frontmost is true)
end tell

try
	tell application myFrontMost
		set windowSize to bounds of window 1
		set windowXl to item 1 of windowSize
		set windowYt to item 2 of windowSize
		set windowXr to item 3 of windowSize
		set windowYb to item 4 of windowSize

		set windowWidth to windowXr - windowXl
		set windowHeight to windowYb - windowYt

		set bounds of window 1 to {¬
			round ((screenWidth - windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight - windowHeight) / 2) rounding as taught in school, ¬
			round ((screenWidth + windowWidth) / 2) rounding as taught in school, ¬
			round ((screenHeight + windowHeight) / 2) rounding as taught in school}
	end tell
end try
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Goodrick-Werner</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-17004</link>
		<dc:creator>Andrew Goodrick-Werner</dc:creator>
		<pubDate>Mon, 15 Nov 2010 00:31:58 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-17004</guid>
		<description>Thank you, Tim, this script is incredibly useful for obsessive people like us.

I&#039;m wondering if it would be at all possible to center windows vertically as well?  I don&#039;t know AppleScript, and can&#039;t seem to figure this out.  Ideally, I&#039;d like my Mail, iTunes, Finder windows, etc. to be centered vertically between the dock and menu bar.</description>
		<content:encoded><![CDATA[<p>Thank you, Tim, this script is incredibly useful for obsessive people like us.</p>
<p>I&#8217;m wondering if it would be at all possible to center windows vertically as well?  I don&#8217;t know AppleScript, and can&#8217;t seem to figure this out.  Ideally, I&#8217;d like my Mail, iTunes, Finder windows, etc. to be centered vertically between the dock and menu bar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Moore</title>
		<link>http://incrementalism.net/tech/centering-windows-in-mac-os-x-with-applescript/comment-page-1#comment-15511</link>
		<dc:creator>Tim Moore</dc:creator>
		<pubDate>Mon, 19 Jul 2010 03:27:53 +0000</pubDate>
		<guid isPermaLink="false">http://incrementalism.net/?p=124#comment-15511</guid>
		<description>Russ,

Normally it should work with whatever window is frontmost, but I can&#039;t guarantee it will work properly in every application, because it depends on their support for AppleScript. I unfortunately don&#039;t have a copy of Microsoft Word to test with, but if anyone has a solution, please let me know and I&#039;ll update the post.</description>
		<content:encoded><![CDATA[<p>Russ,</p>
<p>Normally it should work with whatever window is frontmost, but I can&#8217;t guarantee it will work properly in every application, because it depends on their support for AppleScript. I unfortunately don&#8217;t have a copy of Microsoft Word to test with, but if anyone has a solution, please let me know and I&#8217;ll update the post.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 5/21 queries in 0.080 seconds using disk: basic
Object Caching 440/453 objects using disk: basic
Content Delivery Network via static.incrementalism.net

Served from: incrementalism.net @ 2012-02-06 00:52:29 -->
