Last active
December 16, 2021 00:49
-
-
Save Geroyuni/6c15841bdb1f09566486f3f28cabc08a to your computer and use it in GitHub Desktop.
My useful hotkeys script for Autohotkey
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
#NoTrayIcon | |
#SingleInstance force | |
menus := {} | |
; Alt+Num+B: Move window to a specific portion of the monitor it is in | |
!B:: | |
; Get display the active window is currently in | |
WinGetActiveStats, winTitle, winW, winH, winX, winY | |
SysGet, numDisplays, MonitorCount | |
chosen_index := null | |
Loop %numDisplays% | |
{ | |
SysGet, monitor, MonitorWorkArea, %a_index% | |
if (a_index > 1) ; Left may be skewed on monitors past 1 | |
monitorLeft -= 10 | |
else if (numDisplays > 1) ; Right overlaps Left on monitors past 1 | |
monitorRight -= 10 | |
if (winX >= monitorLeft && winX < monitorRight) ; Tracked based on X | |
chosen_index = %a_index% | |
} | |
if !chosen_index | |
SysGet, chosen_index, MonitorPrimary | |
; Figure out size of the current display | |
SysGet, full, Monitor, %chosen_index% | |
fullWidth := fullRight - fullLeft | |
fullHeight := fullBottom - fullTop | |
halfWidth := fullWidth / 2 | |
halfHeight := fullHeight / 2 | |
halfLeft := fullLeft + halfWidth | |
halfTop := fullTop + halfHeight | |
; Splitscreen games - 2x2 division | |
if (GetKeyState("1") && GetKeyState("2")) | |
WinMove, A, , fullLeft, fullTop, fullWidth, halfHeight | |
else if (GetKeyState("3") && GetKeyState("4")) | |
WinMove, A, , fullLeft, halfTop, fullWidth, halfHeight | |
else if (GetKeyState("1") && GetKeyState("3")) | |
WinMove, A, , fullLeft, fullTop, halfWidth, fullHeight | |
else if (GetKeyState("2") && GetKeyState("4")) | |
WinMove, A, , halfLeft, fullTop, halfWidth, fullHeight | |
else if GetKeyState("1") | |
WinMove, A, , fullLeft, fullTop, halfWidth, halfHeight | |
else if GetKeyState("2") | |
WinMove, A, , halfLeft, fullTop, halfWidth, halfHeight | |
else if GetKeyState("3") | |
WinMove, A, , fullLeft, halfTop, halfWidth, halfHeight | |
else if GetKeyState("4") | |
WinMove, A, , halfLeft, halfTop, halfWidth, halfHeight | |
return | |
; Alt+N: Toggle no title bar/border/menu mode | |
!N:: | |
WinGet hidden, Style, A | |
window := WinExist("A") | |
window_menu := menus[window] | |
; Move window slightly to undo later and avoid glitchy visuals | |
WinGetPos, x, y, w, h | |
WinMove, A, , x+1, y+1, w-1, h-1 | |
; Get menu for current window if there's none in the array yet | |
if (window_menu = null) | |
{ | |
window_menu := (DllCall("GetMenu", "uint", window)) | |
menus[window] := window_menu | |
} | |
; Toggle removal of menu and title bar | |
if (hidden & 0xC40000) | |
{ | |
DllCall("SetMenu", "uint", window, "uint", 0) | |
WinSet, Style, -0xC40000, A | |
if GetKeyState("1") | |
WinMove, A, , x, (y + 30), w, (h - 30) | |
else ; Moving window back to original position to get rid of any glitchy visuals | |
WinMove, A, , x, y, w, h | |
} | |
else | |
{ | |
DllCall("SetMenu", "uint", window, "uint", window_menu) | |
WinSet, Style, +0xC40000, A | |
if GetKeyState("1") | |
WinMove, A, , x, (y - 30), w, (h + 30) | |
else ; Moving window back to original position to get rid of any glitchy visuals | |
WinMove, A, , x, y, w, h | |
} | |
return | |
; Alt+M: Toggle window to always on top | |
!M:: | |
WinSet, Alwaysontop, , A | |
return | |
; Right Alt+Z: Send back slash, for keyboards that lack one | |
RAlt & Z:: | |
Send \ | |
return | |
; Right Alt+X: Send vertical bar, for keyboards that lack one | |
RAlt & X:: | |
Send | | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment