Center Window - Won't Work With Adobe
Posted: Sep 25th, ’24, 22:38
Hello,
I believe I found the following script previously in this forum or another similar forum online. I have an ultra-wide screen monitor, so sometimes I like to center the window to make it a bit easier to read. This script works perfectly with everything except Adobe Acrobat. No matter what document I have open, it will not work. Does anybody have any clues on how to fix that?
Also, for some reason, the window doesn't actually center on Y-axis on my screen. It's about 20 pixels off for some reason. That's why the - 20 is there.
Thanks!
I believe I found the following script previously in this forum or another similar forum online. I have an ultra-wide screen monitor, so sometimes I like to center the window to make it a bit easier to read. This script works perfectly with everything except Adobe Acrobat. No matter what document I have open, it will not work. Does anybody have any clues on how to fix that?
Also, for some reason, the window doesn't actually center on Y-axis on my screen. It's about 20 pixels off for some reason. That's why the - 20 is there.
Code: Select all
WinGetTitle, ActiveWindowTitle, A ; Get the active window's title for "targetting" it/acting on it.
WinGetPos,,, Width, Height, %ActiveWindowTitle% ; Get the active window's position, used for our calculations.
TargetX := (A_ScreenWidth/2)-(Width/2) ; Calculate the horizontal target where we'll move the window.
TargetY := (A_ScreenHeight/2)-(Height/2) - 20 ; Calculate the horizontal target where we'll move the window.
WinMove, %ActiveWindowTitle%,, %TargetX%, %TargetY% ; Move the window to the calculated coordinates.
return