pythonwin32gui

The python win32gui library doesn't give the results I want


I want to get the length and width size information of any application. The code below seems to work partially but gives some wrong results. I tried opening the application in fullscreen, borderless full screen, and window mode, but the result is the same and wrong in all of them.

from win32.win32gui import FindWindow, GetWindowRect

handle = FindWindow(None, "Albion Online Client")
rect   = GetWindowRect(handle)
width = rect[2] - rect[0]
length = rect[3] - rect[1]

print(width,length)
#It gives 1536x864 values for an application with 1920x1080 dimensions.

Does anyone have any ideas? Do you think it has something to do with my 64-bit operating system? I also tried it for 1024x768 and 1680x1050 resolutions. Results are inaccurate with a close ratio.


Solution

  • I fixed the problem!

    I was getting the wrong result because my text and application scaling setting was 125% under display settings in Windows operating system. I changed this setting to 100% and the problem was solved.