KubosKube

Centered Winmove 1.0

Nov 4th, 2025 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 1.64 KB | Software | 0 0
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance Force
  3.  
  4. ; Centered Winmove v1.0
  5. ; A script by Kubos for his girlfriend. You may benefit as well.
  6.  
  7. CoordMode "Mouse", "Screen"
  8.  
  9. /*
  10.     PANIC BUTTONS
  11.    
  12.     Shift + Escape will close the script
  13.    
  14.     Windows + F12 will reload the script
  15. */
  16.  
  17. +Esc:: ExitApp
  18. #F12::
  19. {
  20.     Reload
  21.     SoundBeep 500, 150
  22. }
  23.  
  24.  
  25.  
  26. /*
  27.     Hotkey Quick Reference
  28.    
  29.     Ctrl            ^
  30.     Shift           +
  31.     Alt             !
  32.     Win             #
  33.    
  34.     Left Arrow      Left
  35.     Right Arrow     Right
  36.     Up Arrow        Up
  37.     Down Arrow      Down
  38.  
  39.     Full List of Hotkeys:
  40.         https://www.autohotkey.com/docs/v1/KeyList.htm
  41. */
  42.  
  43. ^+!1:: centered_winmove(1)
  44. ^+!2:: centered_winmove(2)
  45. /*
  46. ^+!3:: centered_winmove(3)
  47. ^+!4:: centered_winmove(4)
  48. ^+!5:: centered_winmove(5)
  49. ^+!6:: centered_winmove(6)
  50. ^+!7:: centered_winmove(7)
  51. ^+!8:: centered_winmove(8)
  52. ^+!9:: centered_winmove(9)
  53. ^+!0:: centered_winmove(10)
  54. */
  55. centered_winmove(mon_id){
  56.    
  57.     MonitorGet mon_id, &mon_left, &mon_top, &mon_right, &mon_bottom
  58.    
  59.     mon_height := mon_bottom - mon_top
  60.     mon_width := mon_right - mon_left
  61.    
  62.     ;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 "."
  63.    
  64.     WinGetPos &win_posx, &win_posy, &win_width, &win_height, "A"
  65.    
  66.     ;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 "."
  67.  
  68.     WinMove (mon_width/2 + mon_left)-(win_width/2), (mon_height/2 + mon_top)-(win_height/2) ,,, "A"
  69.    
  70.     ;WinMaximize "A" ; Comment or De-Comment this line to make the window maximize after moving. Not exactly suggested.
  71. }
Advertisement
Add Comment
Please, Sign In to add comment