{"id":279,"date":"2013-01-30T16:59:28","date_gmt":"2013-01-30T22:59:28","guid":{"rendered":"http:\/\/areciv.com\/blog\/?p=279"},"modified":"2021-09-22T23:17:51","modified_gmt":"2021-09-23T04:17:51","slug":"move-windows-with-hotkeys","status":"publish","type":"post","link":"https:\/\/areciv.com\/blog\/2013\/01\/move-windows-with-hotkeys\/","title":{"rendered":"Move Windows with Hotkeys"},"content":{"rendered":"\n<p>This is a more complicated example of what can be done using <a title=\"AutoHotKey\" href=\"http:\/\/www.autohotkey.com\/\">AutoHotKey<\/a>. I use this script every day at work and pretty much consider it indispensable when using multiple monitors.<\/p>\n\n\n\n<p>Simply, this script lets you use the keyboard to move windows between monitors. Control-Alt-+ moves the window to the same position on the next monitor to the right, while Control-Alt-\u2014 moves the window to the next monitor to the left. Control-Alt-Up can be used to maximize a window across the first two monitors, which comes in really handy when trying to work with multiple Excel workbooks since you can't make it open two instances any more&#8230; Overall, I think the code is pretty easy to follow.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: ahk; title: ; notranslate\" title=\"\">\nSysGet,MaxMonitor,MonitorCount\n\nMenu,Tray,Standard\nMenu,Tray,Add\nMenu,Tray,Add,Increment Window's Monitor Number,IncrementWindowMonitor\nMenu,Tray,Add,Decrement Window's Monitor Number,DecrementWindowMonitor\nMenu,Tray,Add,Maximize Window Across First Two Screens,MultiMaximizeWindow\nreturn\n\n^!NumpadAdd::\nIncrementWindowMonitor:\nGosub,FindCurrentMonitor\n\nIf (CurrMonitor = 0)\nreturn\n\nNewMonitor := CurrMonitor + 1\n\nIf (NewMonitor &lt;= MaxMonitor)\nGosub,MoveCurrentWindow\nreturn\n\n^!NumpadSub::\nDecrementWindowMonitor:\nGosub,FindCurrentMonitor\n\nIf (CurrMonitor = 0)\nreturn\n\nNewMonitor := CurrMonitor - 1\n\nIf (NewMonitor &gt;= 1)\nGosub,MoveCurrentWindow\nreturn\n\n^!Up::\nMultiMaximizeWindow:\nWinGet,WindowState,MinMax,A\nSysGet,LeftMonitor,MonitorWorkArea,1\nSysGet,RightMonitor,Monitor,2\n\nIf (WindowState = 1)\nWinRestore,A\n\nWinMove,A,,0,0,RightMonitorRight,LeftMonitorBottom\nreturn\n\nMoveCurrentWindow:\nWinGet,WindowState,MinMax,A\nSysGet,NewMonitor,Monitor,%NewMonitor%\n\nNewWinX := WinX - MonitorLeft + NewMonitorLeft\nNewWinY := WinY - MonitorTop  + NewMonitorTop\n\nIf (WindowState = 1)\nWinRestore,A\n\nWinMove,A,,%NewWinX%,%NewWinY%\n\nIf (WindowState = 1)\nWinMaximize,A\nreturn\n\nFindCurrentMonitor:\nWinGetPos,WinX,WinY,WinWidth,WinHeight,A\nMidpointX := WinX + (WinWidth \/ 2)\nMidpointY := WinY + (WinWidth \/ 2)\n\nCurrMonitor := 1\nLoop %MaxMonitor%\n{\nSysGet,Monitor,Monitor,%CurrMonitor%\nIf (MidpointX &gt;= MonitorLeft AND MidpointX &lt;= MonitorRight AND MidpointY &gt;= MonitorTop AND MidpointY &lt;= MonitorBottom)\nbreak\nCurrMonitor := CurrMonitor + 1\n}\n\nif (CurrMonitor &gt; MaxMonitor)\n{\nMsgBox What just happened?? This window isn't on an active monitor??\nCurrMonitor := 0\nreturn\n}\nreturn\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>This is a more complicated example of what can be done using <a href=\"http:\/\/www.autohotkey.com\/\" title=\"AutoHotKey\">AutoHotKey<\/a>.  I use this script every day at work and pretty much consider it indispensable when using multiple monitors.<\/p>\n","protected":false},"author":1,"featured_media":4423,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[88],"tags":[49,48,50,51],"class_list":["post-279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-ahk","tag-script","tag-utility","tag-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/areciv.com\/blog\/wp-content\/uploads\/2013\/01\/ahk-logo.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":9,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":4425,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/posts\/279\/revisions\/4425"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/media\/4423"}],"wp:attachment":[{"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/areciv.com\/blog\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}