Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
502 views
in Technique[技术] by (71.8m points)

Win32api is not giving the correct coordinates with GetCursorPos() in python

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()

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are subject to DPI virtualization. Your application has not declared itself aware of high DPI and you have a font scaling of 125%.

If you want to avoid DPI virtualization either add the high DPI aware option to the application manifest or call either SetProcessDPIAware or SetProcessDPIAwareness.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...