Why pyautogui click not actually clicking
Solution 1
Try editing as follows:
from selenium import webdriver
import pyautogui as py
import time
browser=webdriver.Chrome()
browser.maximize_window()
browser.get('http://jao.eu/marketdata/dailyauctions')
#Allows time for webpage to load
time.sleep(5)
#Set clicks parameter to 2
py.click(x=745,y=692, clicks=2, interval=1)
Setting the clicks parameter to 2 within the click() function will make the chrome browser just opened the active window and the second click will click the link at the coordinates entered in the click() function.
Solution 2
For windows I am also running my python-code as admin, cause else it won't recognize the mouse-click.
Also, pyautogui seems to be outdated, I found an upgrade of this library: pydirectinput (https://pypi.org/project/PyDirectInput/)
Solution 3
For me I was using my macbook m1. For Macbooks you need to specifically give permissions to control your device.
Go over to
Apple icon on top left -> System Preferences -> Security & Privacy -> Privacy -> Accessibility
Allow the terminal/code editor
If you see it greyed out click on the lock icon below-left of the window and then you should be able to change the permission.
Related videos on Youtube
nyaki
Updated on June 04, 2022Comments
-
nyaki almost 2 years
I try to use the click function of Pyautogui, but the actual click doesn't happen or at least there is no change at the page though it moves the mouse to the right place.
The window is in focus (I think) because the program works well with other pages.
I could only find one relevant question: having trouble clicking in program - pyautogui. However, there was no accepted answer for that and I tried the given answer in the link but didn't work (It was in python2 but I'm in python3).
I use Linux. I have no idea why the mouse moves to the right place but doesn't perform the click.
The code:
from selenium import webdriver import pyautogui as py import time import pandas as pd browser=webdriver.Firefox() browser.maximize_window() browser.get("http://jao.eu/marketdata/dailyauctions") py.click(x=745,y=692, interval=1)
-
blondelg almost 3 yearsWelcome to SO, please read stackoverflow.com/help/how-to-ask
-
joe over 2 yearsThanks! Running a the powershell as administrator solved it for me (right click -> run as administrator).