Created
February 17, 2023 14:57
-
-
Save jkrasnay/54ad86226278b7cf020e8ab496f9ee55 to your computer and use it in GitHub Desktop.
AutoHotKey script for window management
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
; This is my AutoHotKey script for window management | |
; Each keystroke involves a "mash": holding the Ctrl, Alt, and Windows keys together, | |
; then pressing on of the keys centered around the K key | |
; E.g. Ctrl-Alt-Windows-J moves the current window to the left half of the screen. | |
; | |
; GetCurrentMonitor is from https://www.autohotkey.com/board/topic/85457-detecting-the-screen-the-current-window-is-on/ | |
GetCurrentMonitor() | |
{ | |
SysGet, numberOfMonitors, MonitorCount | |
WinGetPos, winX, winY, winWidth, winHeight, A | |
winMidX := winX + winWidth / 2 | |
winMidY := winY + winHeight / 2 | |
Loop %numberOfMonitors% | |
{ | |
SysGet, monArea, Monitor, %A_Index% | |
if (winMidX > monAreaLeft && winMidX < monAreaRight && winMidY > monAreaTop && winMidY < monAreaBottom) | |
return A_Index | |
} | |
} | |
^!#r:: | |
Reload | |
MsgBox, AutoHotKey reloaded | |
return | |
^!#i:: | |
monIndex := GetCurrentMonitor() | |
SysGet mon, MonitorWorkArea, %monIndex% | |
monWidth := monRight - monLeft | |
monHeight := monBottom - monTop | |
x := monLeft | |
y := monTop | |
w := monWidth | |
h := monHeight | |
WinRestore, A | |
WinMove, A,, %x%, %y%, %w%, %h% | |
return | |
^!#j:: | |
monIndex := GetCurrentMonitor() | |
SysGet mon, MonitorWorkArea, %monIndex% | |
monWidth := monRight - monLeft | |
monHeight := monBottom - monTop | |
x := monLeft | |
y := monTop | |
w := monWidth // 2 | |
h := monHeight | |
WinRestore, A | |
WinMove, A,, %x%, %y%, %w%, %h% | |
return | |
^!#k:: | |
monIndex := GetCurrentMonitor() | |
SysGet mon, MonitorWorkArea, %monIndex% | |
monWidth := monRight - monLeft | |
monHeight := monBottom - monTop | |
x := monLeft + monWidth // 4 | |
y := monTop | |
w := monWidth // 2 | |
h := monHeight | |
WinRestore, A | |
WinMove, A,, %x%, %y%, %w%, %h% | |
return | |
^!#l:: | |
monIndex := GetCurrentMonitor() | |
SysGet mon, MonitorWorkArea, %monIndex% | |
monWidth := monRight - monLeft | |
monHeight := monBottom - monTop | |
x := monLeft + monWidth // 2 | |
y := monTop | |
w := monWidth // 2 | |
h := monHeight | |
WinRestore, A | |
WinMove, A,, %x%, %y%, %w%, %h% | |
return | |
^!#,:: | |
monIndex := GetCurrentMonitor() | |
SysGet mon, MonitorWorkArea, %monIndex% | |
monWidth := monRight - monLeft | |
monHeight := monBottom - monTop | |
x := monLeft + monWidth // 4 | |
y := monTop + monHeight // 4 | |
w := monWidth // 2 | |
h := monHeight // 2 | |
WinRestore, A | |
WinMove, A,, %x%, %y%, %w%, %h% | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment