; Centers any active window to the screen.
; Press Win+C to center any window.
; Created September 2019
; Migrated to AHKv2 June 2026
; Created by Wesley Pyburn (TroubleChute)
; https://github.com/TcNoco/TcNo-Random-Scripts
#c:: {
; Get the active window's ID
activeID := WinExist("A")
; Get the window's size
WinGetPos(, , &sizeW, &sizeH, activeID)
; Get the work area of the monitor containing the window
MonitorGetWorkArea(, &waLeft, &waTop, &waRight, &waBottom)
waWidth := waRight - waLeft
waHeight := waBottom - waTop
; Calculate centered position
newX := waLeft + (waWidth / 2) - (sizeW / 2)
newY := waTop + (waHeight / 2) - (sizeH / 2)
; Move the window
WinMove(newX, newY, , , activeID)
}
Here, i adapted it for AHKv2
Best regards, MT