Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- #SingleInstance Force
- ; Centered Winmove v1.0
- ; A script by Kubos for his girlfriend. You may benefit as well.
- CoordMode "Mouse", "Screen"
- /*
- PANIC BUTTONS
- Shift + Escape will close the script
- Windows + F12 will reload the script
- */
- +Esc:: ExitApp
- #F12::
- {
- Reload
- SoundBeep 500, 150
- }
- /*
- Hotkey Quick Reference
- Ctrl ^
- Shift +
- Alt !
- Win #
- Left Arrow Left
- Right Arrow Right
- Up Arrow Up
- Down Arrow Down
- Full List of Hotkeys:
- https://www.autohotkey.com/docs/v1/KeyList.htm
- */
- ^+!1:: centered_winmove(1)
- ^+!2:: centered_winmove(2)
- /*
- ^+!3:: centered_winmove(3)
- ^+!4:: centered_winmove(4)
- ^+!5:: centered_winmove(5)
- ^+!6:: centered_winmove(6)
- ^+!7:: centered_winmove(7)
- ^+!8:: centered_winmove(8)
- ^+!9:: centered_winmove(9)
- ^+!0:: centered_winmove(10)
- */
- centered_winmove(mon_id){
- MonitorGet mon_id, &mon_left, &mon_top, &mon_right, &mon_bottom
- mon_height := mon_bottom - mon_top
- mon_width := mon_right - mon_left
- ;MsgBox "Monitor " mon_id"`n`nBounding Box:`n Left: " mon_left "`n Right: " mon_right "`n Top: " mon_top "`n Bottom: " mon_bottom "`n`n Width: " mon_width "`n Height: " mon_height "."
- WinGetPos &win_posx, &win_posy, &win_width, &win_height, "A"
- ;MsgBox "Window`n`nBounding Box:`n win_posx: " win_posx "`n win_posy: " win_posy "`n`n win_width: " win_width "`n win_height: " win_height "."
- WinMove (mon_width/2 + mon_left)-(win_width/2), (mon_height/2 + mon_top)-(win_height/2) ,,, "A"
- ;WinMaximize "A" ; Comment or De-Comment this line to make the window maximize after moving. Not exactly suggested.
- }
Advertisement
Add Comment
Please, Sign In to add comment