document.write("<script language=\"javascript1.2\" type=\"text/javascript\">function emo_pop() {window.open('http://www.haloscan.com/commenthelp.php','Help','width=200,height=360,resizable=yes,scrollbars=yes');}</script><table width=\"95%\" align=\"center\" cellpadding=\"8\" cellspacing=\"10\" border=\"0\" class=\"MainTable\">  <tr>    <td>    <div align=\"center\"><p><div style=\"font-size:14px; margin-top: 15px; padding-top: 10px; border-top-style: solid; border-top-width: 1px;\">Comments</div></p>    </div>    </td>  </tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"95596\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=4a8b9629f2323606174fd36ace0cdad8&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />This works great. The only problem is when using Spaces, you have to run the script for each Space that is open. Is there a way to have all windows gathered on all Spaces at once? A main reason I use it is bc my Firefox (2.0.0.111) always opens a new window on my extended desktop when I first open it. Also, when in Spaces, and switching from Extended Desktop (turn off Mirroring) to Mirroring and back to Extended Desktop (turn off Mirroring) , random windows (eg. Mail, iCal) get shunted over to the extended desktop. If my projector (my extra-monitor) is off, it means I'm losing random windows and have to use Expose to find them.-Thanks!<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Ronin Damascus | 02.07.08 - 10:31 am | <a href=\"#95596\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"98650\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=aa572a7005a315a1e268cd89298d81b1&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />I am having this same issue Ronin.  The script works great for my one primary space.  But I would like it to run on all my configured spaces.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           bryan kennedy | <a href=\"http://www.mysteryexperiece.com\" title=\"http://www.mysteryexperiece.com\">Homepage</a> | 03.18.08 - 6:16 pm | <a href=\"#98650\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"98749\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=e50f29c0a8114e5a37556b4830871cb8&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />It really works!!! Very thank you, It maximizes my life! cheers<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           flats | <a href=\"http://www.flats.com\" title=\"http://www.flats.com\">Homepage</a> | 03.20.08 - 9:48 am | <a href=\"#98749\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"101714\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Sweet!<br><br>You saved my headache getting bigger.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           MAXp0wr | 04.23.08 - 9:14 am | <a href=\"#101714\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"106583\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=ea05b5214242211e22fe7aacc714c150&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />You Sir (or madam), are a genius! Cheers for an great tip, and very thoroughly and clearly explained! Thank-You!<br><br>ps, I don't use spaces very much so I haven't experienced the problem that others are having.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Ali | 06.23.08 - 11:28 am | <a href=\"#106583\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"112535\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />I was excited whey I found this post, and it seems to work for most apps.  But Terminal doesn't appear to be one of them.  I still have a rogue Terminal window floating way off my screen when I unplug from my 30\" display at work.  Very frustrating...<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Andrew | 08.22.08 - 10:37 pm | <a href=\"#112535\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"115121\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=8dd19db77eba33d95eaa78c38143ee9f&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Great script!  Thanks!<br><br>I've made one tweak to it that works well for me.<br><br>At home since I don't tend to use the internal display of the laptop, I wake the computer with the lid shut so it disables that display.<br><br>I often end up with windows at the far right edge of the display with only 20 pixels or so on the display.<br><br>In order to bring them back to a usable place, you have to grab very carefully around the close button to get a grip.<br><br>This updated version of the script detects windows that have their right edge of the screen and brings them back on the right side of the display.<br><br>Per one of the comments above, I tested it with both iTerm and Terminal and it seems to work for me with both as of 10.5.4.<br><br>Thanks again!<br><br>----<br><br>property processesToIgnore : {}<br><br>tell application \"Finder\"<br>set _b to bounds of window of desktop<br>set screen_width to item 3 of _b<br>set screen_height to item 4 of _b<br>end tell<br><br>tell application \"System Events\"<br>set allProcesses to application processes<br>set _results to \"\"<br>repeat with i from 1 to count allProcesses<br>set doIt to 1<br>repeat with z from 1 to count processesToIgnore<br>if process i = process (item z of processesToIgnore) then<br>set doIt to 0<br>end if<br>end repeat<br>if doIt = 1 then<br>tell process i<br>--  Let's make this guarantee that windows off to the right side are brought<br>-- entirely on-screen.<br>--<br>-- This solves an issue when switching from an internal main display<br>-- to an external one where windows are often at the farthest right<br>-- edge of the screen and you have to grab them near the close button<br>repeat with x from 1 to (count windows)<br>set winPos to position of window x<br>set _x to item 1 of winPos<br>set _y to item 2 of winPos<br>set winSize to size of window x<br>set _w to item 1 of winSize<br>if (_x < 0 or _y < 0) then<br>set position of window x to {0, 22}<br>else if ((_x + _w) > screen_width or _y > screen_height) then<br>set position of window x to {screen_width - _w, 0}<br>end if<br>end repeat<br>end tell<br>end if<br>end repeat<br>end tell<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Jim | 09.13.08 - 1:43 pm | <a href=\"#115121\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"121159\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=09cb20901a485141b1bcf10a7b01b943&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />I can't believe I had to do this!  Thanks - the first script I found didn't work but this one did!<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Murphy Mac | <a href=\"http://murphymac.com\" title=\"http://murphymac.com\">Homepage</a> | 11.11.08 - 2:46 am | <a href=\"#121159\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"123938\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />This script saved my bacon - Thanks!<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           OpenSourceIT | 01.09.09 - 2:34 pm | <a href=\"#123938\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"124061\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=aa7c1350d93036592f58f165318044db&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Didn't work for me - my vim window won't come back no matter what I do <img src=\"http://www.haloscan.com/images/smileys/pascontent.gif\" border=\"0\" alt=\"\" width=\"15\" height=\"15\" /><br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Bill Mill | <a href=\"http://billmill.org\" title=\"http://billmill.org\">Homepage</a> | 01.20.09 - 6:10 pm | <a href=\"#124061\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"124067\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=6653380a5b59e7625eee4b83e130ef3b&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Or just right click on the dock icon and choose \"reset windows\" - couldn't get your trick to work with an AIR-app.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           paljoakim | <a href=\"http://paljoakim.com/blog\" title=\"http://paljoakim.com/blog\">Homepage</a> | 01.21.09 - 3:53 pm | <a href=\"#124067\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"125316\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=3d268039956427e74d26b622223b6ae6&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Lifesaver.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Dan | 03.12.09 - 5:25 pm | <a href=\"#125316\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"125891\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=cfd400a115541b7bd8c4e11d5c11abdf&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />This didnt work until I looked carefully at how it was setting the screen size.  I have a Macbook that sometimes also has a 2nd screen which is configured to the be on the right of the macbook.<br>So I sometime \"lose\" windows off to the right when the 2nd screen isnt there.<br><br>The third line of the script:<br>get bounds of window of desktop<br><br>returns{0, -160, 2560, 864}<br><br>but my actual screen pixels ( from the system preferences) is 1280 by 864.<br><br>So my very simple hack was to replace the lines<br><br>set    screen_width to item 3 of _b<br>set screen_height to item 4 of _b<br><br>to<br>set screen_width to 1280<br>set screen_height to 800<br><br>I'm sure there's a better way of doing this to be a more general solution but it works for me<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Kazza in Oz | 04.02.09 - 11:23 pm | <a href=\"#125891\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"127776\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />You saved my sanity. I know nothing about apple script but got this to work.<br>Thank you.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Anthony Grant | <a href=\"http://argstudios.com\" title=\"http://argstudios.com\">Homepage</a> | 06.19.09 - 4:42 pm | <a href=\"#127776\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"127900\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=11c64463ab809441c83add904bdd20ec&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Awesome.  Thanks!<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Reid | <a href=\"http://reidcarlberg.com\" title=\"http://reidcarlberg.com\">Homepage</a> | 06.21.09 - 11:47 am | <a href=\"#127900\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"127994\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Works Great!, <br><br>I use Autopilot(http://www.activata.co.uk) to trigger this script with a hotkey.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           John | 06.23.09 - 5:21 pm | <a href=\"#127994\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"130045\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />Fantastic!  I have a secondary display hooked up to my iMac.  I turn off the other display periodically and am forever having to figure out where an errant window has gone off to.  This eliminates the search process!<br><br>Thanks for crafting this elegant script.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Steven | 09.15.09 - 3:50 am | <a href=\"#130045\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"130408\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=d41d8cd98f00b204e9800998ecf8427e&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />I can't believe you have to write a script to do this. Why is such a basic accessibility feature missing from OSX?<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           Colin | 10.02.09 - 2:36 am | <a href=\"#130408\" title=\"Link to this comment\">#</a></span></p></td></tr><tr><td class=\"MessageCell\" bgcolor=\"#EBEBEB\" style=\"border:1px solid #ccc;\">    <a name=\"131450\"></a>        <p><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=e308c66e5fca1c9ba8055f922b89a8a9&amp;default=http%3A%2F%2Fwww.macosxtips.co.uk%2Fgravatar.png&amp;rating=PG&amp;size=60\" alt=\"Gravatar\" title=\"Gravatar\" style=\"padding: 1px; margin: 2px; float: right;\" class=\"gravatar\" />This helped so much! Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! And I agree, I think this should've been easier than writing script to fix this issue.<br /><span class=\"byline\" style=\"font-family:Tahoma; font-size:11px; color:#666; text-align:right;\">           sgee | 11.18.09 - 7:09 am | <a href=\"#131450\" title=\"Link to this comment\">#</a></span></p></td></tr><tr>    <td class=\"InputCell\">                  <div id=\"newcomment\"></div><form method=\"post\" name=\"addComment\" action=\"http://www.haloscan.com/comments/mattswain123/rw_unique_entry_id_163_page0/\" target=\"_self\">        <p>    Name: <br />          <input name=\"name\" type=\"text\" size=\"38\" value=\"\" /><br />          Email:<br />          <input name=\"email\" type=\"text\" size=\"38\" value=\"\" /><br />          URL: <br />          <input name=\"url\" type=\"text\" size=\"38\" value=\"\" /><br />          Comment:&nbsp;&nbsp;<a href=\"javascript:emo_pop()\" title=\"Smiley and tag help\" target=\"_self\">?</a>&nbsp;<br />          <textarea name=\"addMessage\" rows=\"12\" cols=\"38\"></textarea><br /><input type=\"checkbox\" name=\"subscribe\" id=\"subscribe\" value=\"1\" /><label for=\"subscribe\">Notify me of followup comments via email</label>        </p>        <p class=\"PSubmit\"><input name=\"submit\" type=\"submit\" value=\"Publish\" style=\"font-weight: bold;\" class=\"SubmitButton\" />&nbsp;<input name=\"previewMessage\" type=\"submit\" value=\"Preview\" class=\"SubmitButton\" />        </p>      <input type='hidden' name='user' value='mattswain123' /><input type='hidden' name='comment' value='rw_unique_entry_id_163_page0' /></form>    </td></tr></table><img src=\"http://c5.statcounter.com/counter.php?sc_project=561713&amp;java=0&amp;security=01eeff58\" alt=\"\" border=\"0\" /></body>");