asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.45k stars 1.26k forks source link

Click Intervals on Mac not working properly #369

Closed UkwaA closed 4 years ago

UkwaA commented 5 years ago

I'm running Mac OS Mojave and when trying to use the click function with an intervals argument it seems like the intervals aren't working. According to the documentation's example, an interval of .25 is a quarter of a second, but when I put 10 in to represent 10 seconds all of the clicks still seemed to happen instantaneously. I even tried 100000 just to see if I was misinterpreting but they still happened instantaneously. Is anyone else having this problem on Mac?

JayRizzo commented 5 years ago

I have this issue as well on Mac OS Mojave 10.14.6 for over a month now. I cannot figure out why as there is no issues or warnings in my terminal as I test it.

from pyautogui import click
click(clicks=2, interval=0.25)

Behaves the same way as

from pyautogui import click
click(clicks=2000, interval=0.25)

I have tried

Currently Using:

JayRizzo commented 5 years ago

So, I think I found the location of the culprit!

This has been bothering me, so, I found a temporary work around for now, still looking into as to why...

Work around for Mac OSX is to install an earlier version.

pip3 install 'pyautogui==0.9.44'

Something functionally broke in:

pip3 install 'pyautogui>=0.9.45'

That caused this to happen.

From the change log: v0.9.45, 2019/06/18 -- Added left-click, made mouse buttons more explicit and fixed it so that the right mouse button is 2 and middle mouse button is 3. Added failsafe points in all corners. Added screenshot logging. Fixed _autoPause().

Looking deeper: I suspect it may be the changed file of pyautogui/_pyautogui_osx.py in the 0.9.45 update.

JayRizzo commented 5 years ago

I believe this is the culprit: https://github.com/asweigart/pyautogui/commit/967bdc3d8d24ee4bf1e558b70d49a9d2dd4fe31e#r35260398

UkwaA commented 5 years ago

So, I think I found the location of the culprit!

This has been bothering me, so, I found a temporary work around for now, still looking into as to why...

Work around for Mac OSX is to install an earlier version.

pip3 install 'pyautogui==0.9.44'

Something functionally broke in:

pip3 install 'pyautogui>=0.9.45'

That caused this to happen.

From the change log: v0.9.45, 2019/06/18 -- Added left-click, made mouse buttons more explicit and fixed it so that the right mouse button is 2 and middle mouse button is 3. Added failsafe points in all corners. Added screenshot logging. Fixed _autoPause().

Looking deeper: I suspect it may be the changed file of pyautogui/_pyautogui_osx.py in the 0.9.45 update.

Your solution worked! Thank you very much.

JayRizzo commented 5 years ago

@UkwaA I created a PR #375 that should fix this issue going forward. Check out my code and let me know if it works for you too.

asweigart commented 4 years ago

Fixed by PR #375