Advertisement
slyfox1186

maximize-and-move-windows-v2.ahk

Jun 28th, 2021 (edited)
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Maximize and Move Windows v2
  3.  
  4.     Created by: SlyFox1186
  5.     Pastebin: https://pastebin.com/u/slyfox1186
  6.     Required: AutoHotkey.exe
  7.  
  8.     This script will move all windows that match the process names defined inside the expression.
  9.     All windows will be centered according to the screen's dimensions.
  10.  
  11.     Add window names inside the '_procNames' variable below.
  12.     Add each name on its own line.
  13.     Do not include '.exe' at the end of each name.
  14. */
  15.  
  16. #Persistent
  17. #SingleInstance, Force
  18.  
  19. !c::
  20. _procNames := "
  21. (
  22. cmd
  23. debian
  24. Discord
  25. mintty
  26. Steam
  27. Spotify
  28. )"
  29.  
  30. _procNames := RegExReplace(_procNames, "([a-zA-Z\d]+)", Replacement := "$1.exe")
  31. Loop Parse, % _procNames, `n
  32. {
  33.     WinGet, win, PID, ahk_exe %A_LoopField%
  34.     WinGet, _IsMax, MinMax, ahk_pid %win%
  35.     If (_IsMax = 1)
  36.         WinActivate, ahk_pid %win%
  37.         WinGetPos,,, _Width, _Height, ahk_pid %win%
  38.         WinMove, ahk_pid %win%,, (A_ScreenWidth/2)-(_Width/2), (A_ScreenHeight/2)-(_Height/2)
  39. }
  40. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement