Page 1 of 1

Center Window - Won't Work With Adobe

Posted: Sep 25th, ’24, 22:38
by gsechler
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.

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
Thanks!

Re: Center Window - Won't Work With Adobe

Posted: Oct 1st, ’24, 19:10
by Marko
Does this work?

Code: Select all

WinGetPos,,, Width, Height, A
WinMove A,, (A_ScreenWidth-Width)/2, (A_ScreenHeight-Height)/2
or

Code: Select all

SysGet Mon, MonitorWorkArea
WinGetPos,,, Width, Height, A
WinMove A,, (MonRight-Width)/2, (MonBottom-Height)/2

Re: Center Window - Won't Work With Adobe

Posted: Oct 4th, ’24, 02:45
by gsechler
Second one works perfectly! Thanks so much for the help!