问题
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