简体   繁体   English

错误的光标移动 win32api

[英]Wrong cursor movement win32api

I am trying to move my cursor with win32api.我正在尝试使用 win32api 移动我的光标。 I need to move to the point mid_x and mid_y knowing my current cursor position(x,y).我需要移动到点 mid_x 和 mid_y 知道我当前的光标位置(x,y)。

x, y = win32api.GetCursorPos()

Then, I find how much should i move.然后,我找到我应该移动多少。

dx = int(mid_x -x)
dy= int(mid_y - y)

Finally, i move my cursor!最后,我移动我的光标!

win32api.mouse_event(0x0001, dx,dy, 0, 0)

In the end, my mouse moves in a wrong direction.最后,我的鼠标移动到了错误的方向。 I read a c++ documentation and found that dx and dy should be a mickey value .我阅读了一个 c++ 文档,发现 dx 和 dy 应该是一个mickey value What does that mean and how can i change it to pixels?这是什么意思,我如何将其更改为像素?

//get the Screen resolution.
scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

//get the scale(a screen has 65535*65535 mickey value)
scalex = 65535 / scalex;
scaley = 65535 / scaley;

win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM