How application get mouse movement when using pyautogui

雨燕双飞 提交于 2021-01-29 02:37:09

问题


When I move mouse without pyautogui pass by a application, for example windows calculator, button of calculator will change it's color. It seems that, calculator captured the movement of my mouse.
Like this, you can see button 9 color changed to gray:


But when I use pyautogui, invoke pyautogui.moveTo function. I can see the mouse cursor move to the correct location, but button 9's color keep white.

I'm sure that the x,y possion pass to function pyautogui.moveTo is correct. If I invoke pyautogui.click(), number 9 is showed on calculator.

Is there any way to ensure that application recognize the movement triggered by pyautogui?

Thank you


回答1:


Well Although I don't really see a problem here if it bugs you that much try to use the third argument for the moveTo() function.

>>> pyautogui.moveTo(100, 200, 2)   # moves mouse to X of 100, Y of 200 over 2 seconds

Here it will slide over slowly in two seconds and will give the hover effect. If the duration is less than pyautogui.MINIMUM_DURATION the movement will be instant. By default, pyautogui.MINIMUM_DURATION is 0.1.

Hope this helps.



来源:https://stackoverflow.com/questions/54473989/how-application-get-mouse-movement-when-using-pyautogui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!