Win32api 没有在 python 中使用 GetCursorPos() 给出正确的坐标 [英] Win32api is not giving the correct coordinates with GetCursorPos() in python
问题描述
使用 pywin 的 win32api 时,我得到的光标位置值不正确.我的屏幕分辨率为 1920x1080,但是当我使用 GetCursorPos() 时,左上角有 (0,0),右下角有 (1535,863).我使用的代码如下:
When using the win32api from pywin, I am getting incorrect values for the cursor position. My screen's resolution is 1920x1080, but when I use GetCursorPos() I have (0,0) in the top left and (1535,863) in the bottom right. The code I am using is as follows:
import win32api
def getCursor():
print win32api.GetCursorPos()
我正在 Windows 10 上使用 python 2.7 尝试此操作,但我也在 Windows 8 上的 python 2.6 中遇到此错误.是否有解决此问题的方法或解决方法?
I am trying this using python 2.7 on windows 10, but I was also getting this error in python 2.6 on windows 8. Is there any solution or workaround to this problem?
推荐答案
您必须遵守 DPI 虚拟化.您的应用程序尚未声明自己意识到高 DPI,并且您的字体缩放比例为 125%.
You are subject to DPI virtualization. Your application has not declared itself aware of high DPI and you have a font scaling of 125%.
如果您想避免 DPI 虚拟化,请将高 DPI 感知选项添加到应用程序清单或调用 SetProcessDPIAware
或 SetProcessDPIAwareness
.
If you want to avoid DPI virtualization either add the high DPI aware option to the application manifest or call either SetProcessDPIAware
or SetProcessDPIAwareness
.
这篇关于Win32api 没有在 python 中使用 GetCursorPos() 给出正确的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!