Skip to content

Instantly share code, notes, and snippets.

@daftspaniel
Created December 30, 2022 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daftspaniel/c2a443efffe376b90855cd868ac5e170 to your computer and use it in GitHub Desktop.
Save daftspaniel/c2a443efffe376b90855cd868ac5e170 to your computer and use it in GitHub Desktop.
AutoHotkey 2.0 Window Controls
; HOTKEYS - Ctrl + F1 etc
^F1::CenterActiveWindow()
^F2::FocusActiveMinOthers()
^F3::NarrowActiveWindow()
CenterActiveWindow()
{
windowWidth := A_ScreenWidth * 0.9 ; desired width
windowHeight := A_ScreenHeight * 0.92 ; desired height
windowName := WinGetTitle("A")
WinRestore windowName
WinMove A_ScreenWidth/2-(windowWidth/2), 25, windowWidth, windowHeight, windowName
}
FocusActiveMinOthers()
{
windowName := WinGetTitle("A")
WinMinimizeAll
WinRestore windowName
CenterActiveWindow()
}
NarrowActiveWindow()
{
windowWidth := A_ScreenWidth * 0.5 ; desired width
windowHeight := A_ScreenHeight * 0.92 ; desired height
windowName := WinGetTitle("A")
WinRestore windowName
WinMove A_ScreenWidth/2-(windowWidth/2), 25, windowWidth, windowHeight, windowName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment