Reputation: 37
there was a question similar to this (Why pyautogui click not actually clicking) but this didnt work for me. I have given pycharm (what I'm using) accessibility privileges but it still doesn't work :( here is my code:
import pyautogui, time
time.sleep(1)
pyautogui.moveTo(235, 135, duration=1)
pyautogui.click()
time.sleep(0.1)
pyautogui.click(clicks=3, interval=0.1)
Upvotes: 0
Views: 2367
Reputation: 69
This is how I got around this issue in my code:
if moveVar.get() == True:
pyautogui.PAUSE = iCoor1[0]
pyautogui.moveTo(x=xyCoor1[0], y=xyCoor2[0], duration=0.2, _pause=False)
pyautogui.click(x=xyCoor1[0], y=xyCoor2[0], clicks=cCoor1[0], button='left')
elif moveVar.get() == False:
pyautogui.PAUSE = iCoor1[0]
pyautogui.click(x=xyCoor1[0], y=xyCoor2[0], clicks=cCoor1[0], button='left')
Basically assigned a variable to the X and Y position and just used moveTo
and then clicked.
for the variable you can simply do x, y = pyautogui.position()
and then just assign the x & y value to the parameters, then call the variables again straight after you move, to click.
Upvotes: 0
Reputation: 26
pyautogui.click() didn't work for me either I worked around it by using the mouse down and mouse up options...
pyautogui.mouseDown(button='left')
pyautogui.mouseUp(button='left')
just for convenience I made it into a function...
def click(button):
pyautogui.mouseDown(button=button)
pyautogui.mouseUp(button=button)
after which the following worked fine...
click('left')
Upvotes: 1