I created a script that automatically sets the window size for certain apps. I put it in Startup so it works independetly. I needed this because I have a laptop with 2560x1600 screen resolution and I use it for work. But when I’m at home, I connect it to my Full HD monitor. The problem is that some apps change their size because of different screen resolutions and it’s very annoying to always resize them manually. So I did this:
#Persistent
GroupAdd, ResizedWin, ahk_exe telegram.EXE
GroupAdd, ResizedWin, ahk_exe Discord.EXE
GroupAdd, ResizedWin, ahk_exe WhatsApp.EXE
GroupAdd, ResizedWin, ahk_exe Notepad.EXE
Loop
{
WinWait ahk_group ResizedWin
WinMove, , , , , 1417, 915
WinWaitClose
}
This is the perfect size for these apps for me. But the current problem is that it’s perfect for WQHD resolution. On FHD it is obviously enormous.
My question is, is there any way to correct the window size so it would look the same both on WQHD and FHD displays? It may be important, but when I use FHD monitor, the laptop is closed, so the WQHD display is inactive. And vice versa, when I use WQHD display the FHD monitor isn’t even connected.
What I have already found in WinMove documentation of AHK is this:
CenterWindow(WinTitle)
{
WinGetPos,,, Width, Height, %WinTitle%
WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}
You can see there is an interesting (A_ScreenWidth/2)-(Width/2) and (A_ScreenHeight/2)-(Height/2) for centering the window. So it is somehow possible, but I’m not sure will it work with width and height of the window. What is more important is that I have no idea how to calculate it, like how much should I divide the screen resolution. If it is 1417x915 on 2560x1600, how much it will be on 1920x1080.
So that is just my assumption. Maybe there is another way?