Created
July 18, 2018 00:29
-
-
Save domwrap/49bcd17083a79eafcde69afd3fb8c70e to your computer and use it in GitHub Desktop.
Quick script to put program windows back on a specified screen. Made to make life easier when constantly (un)docking my laptop from two monitors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; REQUIRES AutoHotKey | |
; https://autohotkey.com/ | |
#NoEnv | |
#Persistent | |
#SingleInstance Force | |
SetTitleMatchMode, 2 | |
; ================================ | |
; CHANGE THIS TO YOUR OWN PREFERENCES | |
; Key:Value list of program name (from Window Spy) to screen number, | |
; determines which programs go on which monitor, where 1 = left-most | |
; Currently limited to 3 screens, but very easily expanded | |
arrWindows := { OUTLOOK: 3, chrome: 2 } | |
; ================================ | |
; LEAVE THE REST | |
; ================================ | |
; BELOW BE DRAGONS | |
; ================================ | |
; Retrieve size and coords of each screen | |
; Weirdly monitor 1 == 0, so we skip it | |
SysGet, Mon0, Monitor, 0 | |
SysGet, Mon2, Monitor, 2 | |
SysGet, Mon3, Monitor, 3 | |
arrPos := [ Mon0Left, Mon2Left, Mon3Left ] | |
; Drink the potion, GUMMY BEEEEARS! | |
; Window window boing boing | |
for strExe, intMon in arrWindows | |
{ | |
; Find all windows of each defined exe | |
WinGet, arrFound, list, ahk_exe %strExe%.exe | |
; Iterate over found windows and move them to specified screen | |
i := 1 | |
Loop | |
{ | |
; Have to compile this outside each command due to AHK's weird interpreter | |
idWin = % arrFound%i% | |
; Such move. Much maximize. Wow. | |
WinActivate, ahk_id %idWin% | |
WinRestore, ahk_id %idWin% | |
WinSet, Style, 0x40000 | |
WinSet, Redraw | |
WinMove, ahk_id %idWin%, , arrPos[intMon], 0 | |
WinMaximize, ahk_id %idWin% | |
i++ | |
} | |
Until i = arrFound+1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment