what i would do is instead of going

import pyautogui
pyautogui.FAILSAFE = True
while True:
    cash = pyautogui.locateOnScreen('cash.png',confidence=0.8)
    if cash != None:
        pyautogui.click(cash)

you would do

import pyautogui
pyautogui.FAILSAFE = True
while True:
    cash = pyautogui.locateOnScreen('cash.png',confidence=0.8)
    if cash != None:
    pyautogui.move(cash)
        pyautogui.click(cash)

your problem is that the program is just going to run click but it doesnt know to actually move there and THAN click.

Answer from Seth Israel on Stack Overflow
๐ŸŒ
PyAutoGUI
pyautogui.readthedocs.io โ€บ en โ€บ latest โ€บ mouse.html
Mouse Control Functions โ€” PyAutoGUI documentation
To specify a different mouse button to click, pass 'left', 'middle', or 'right' for the button keyword argument: >>> pyautogui.click(button='right') # right-click the mouse
Installation
To install PyAutoGUI, install the pyautogui package from PyPI by running pip install pyautogui (on Windows) or pip3 install pyautogui (on macOS and Linux).
Keyboard Control Functions
To make holding a key convenient, the hold() function can be used as a context manager and passed a string from the pyautogui.KEYBOARD_KEYS such as shift, ctrl, alt, and this key will be held for the duration of the with context block.
Cheat Sheet
This is a quickstart reference to using PyAutoGUI. PyAutoGUI is cross-platform GUI automation module that works on Python 2 & 3.
Screenshot Functions
PyAutoGUI can take screenshots, save them to files, and locate images within the screen. This is useful if you have a small image of, say, a button that needs to be clicked and want to locate it on the screen.
Discussions

Click relative to mouse cursor position(pyautogui)
I don't think so, at least not with pyautogui, AFAIK. Could you explain the reason behind wanting to click somewhere without moving the mouse? That info might be useful, people could give you alternatives. More on reddit.com
๐ŸŒ r/learnpython
2
1
April 13, 2019
Python pyautogui.click is right clicking instead of left clicking - Stack Overflow
When I use pyautogui.click() in my code, it right clicks instead of left clicking like it should. More on stackoverflow.com
๐ŸŒ stackoverflow.com
pyautogui click problem
Full source below: import cv2 import random import pyautogui from time import sleep import numpy as np pyautogui.FAILSAFE=True rng=random.uniform(0.87, 1.3) sleep(5) pyautogui.size() print(pyautogui.size()) pyautogui.position() print(pyautogui.position()) sleep(5) pyautogui.moveTo(x=1344, y=342, duration=rng) pyautogui.click(clicks=5, interval=0.1) More on reddit.com
๐ŸŒ r/learnpython
15
1
January 10, 2023
python - Pyautogui mouse clicks without actually moving the mouse - Stack Overflow
I'd like to know if it's possible to automate clicks with pyautogui without compromising the funcionality of my cursor. I automate clicks with pyautogui but my cursor becomes useless while the scri... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
PyAutoGUI
pyautogui.readthedocs.io โ€บ en โ€บ latest โ€บ quickstart.html
Cheat Sheet โ€” PyAutoGUI documentation
All clicks can be done with click(), but these functions exist for readability. Keyword args are optional: >>> pyautogui.rightClick(x=moveToX, y=moveToY) >>> pyautogui.middleClick(x=moveToX, y=moveToY) >>> pyautogui.doubleClick(x=moveToX, y=moveToY) >>> pyautogui.tripleClick(x=moveToX, y=moveToY)
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ click relative to mouse cursor position(pyautogui)
r/learnpython on Reddit: Click relative to mouse cursor position(pyautogui)
April 13, 2019 -

Is there a way to click relative to the mouse cursor position with pyautogui? I know you can drag relative by using pyautogui.dragRel() but is there a way to click, or just click without moving the mouse at all. I am trying to create this for a program in a game. (not for a macro/malicious reaons) But when I just use pyautogui.click() it completely changes where I am looking.

Thanks for your help

๐ŸŒ
Read the Docs
pyautogui.readthedocs.io
Welcome to PyAutoGUIโ€™s documentation! โ€” PyAutoGUI documentation
When it finds one, it clicks the ingredient buttons to make the sushi. It also clicks the phone in the game to order more ingredients as needed. The bot is completely autonomous and can finish all seven days of the game. This is the kind of automation that PyAutoGUI is capable of.
Find elsewhere
๐ŸŒ
Automate the Boring Stuff
automatetheboringstuff.com โ€บ 3e โ€บ chapter23.html
Chapter 23 - Controlling the Keyboard and Mouse, Automate the Boring Stuff with Python, 3rd Ed
You can pass x- and y-coordinates of the click as optional first and second arguments if you want it to take place somewhere other than the mouseโ€™s current position. If you want to specify which mouse button to use, include the button keyword argument, with a value of 'left', 'middle', or 'right'. For example, pyautogui.click(100, 150, button='left') will click the left mouse button at the coordinates (100, 150), while pyautogui.click(200, 250, button='right') will perform a right-click at (200, 250).
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ PyAutoGUI
PyAutoGUI ยท PyPI
PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2. ... Tags gui , automation , test , testing , keyboard , mouse , cursor , click , press , keystroke , control
      ยป pip install PyAutoGUI
    
Published ย  May 24, 2023
Version ย  0.9.54
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ pyautogui click problem
r/learnpython on Reddit: pyautogui click problem
January 10, 2023 -

Hello, everyone! Need to mention that im new with Python and i decided to create a bot for multiplayer game, to autobuy items on auctionhouse, using opencv and pyautogui, so far everything was going pretty well, the cursor was heading to the right point on the screen (reload auction), but

pyautogui.click(clicks=2) isnt working in game window.

IDE (PyCharm) is running with admin rights, googled alot about the topic, also tried pydirectinput, but nothing works so far. Will be pleased if anyone could help me, this is my first big project i really want to work with, so hopefully you guys can help me :D

additional info: game engine Java (probably... Game is called Stalcraft, you can find it on steam, looks like its something Minecraft-based, but im not sure about it)
OS: Win 10 x64

๐ŸŒ
PyAutoGUI
pyautogui.readthedocs.io โ€บ en โ€บ latest โ€บ screenshot.html
Screenshot Functions โ€” PyAutoGUI documentation
>>> import pyautogui >>> button7location = pyautogui.locateOnScreen('calc7key.png') >>> button7location Box(left=1416, top=562, width=50, height=41) >>> button7location[0] 1416 >>> button7location.left 1416 >>> button7point = pyautogui.center(button7location) >>> button7point Point(x=1441, y=582) >>> button7point[0] 1441 >>> button7point.x 1441 >>> button7x, button7y = button7point >>> pyautogui.click(button7x, button7y) # clicks the center of where the 7 button was found >>> pyautogui.click('calc7key.png') # a shortcut version to click on the center of where the 7 button was found
๐ŸŒ
Automate the Boring Stuff
automatetheboringstuff.com โ€บ 2e โ€บ chapter20
20 controlling the keyboard and mouse with gui automation
The pyautogui module can send virtual keypresses and mouse clicks to Windows, macOS, and Linux. Windows and macOS users can simply use pip to install PyAutoGUI. However, Linux users will first have to install some software that PyAutoGUI depends on.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ anyone here good with pyautogui? need some help
r/learnpython on Reddit: Anyone here good with pyautogui? Need some help
September 20, 2021 -

Hey i need some help figuring out how to press and hold the left mouse button for an extended period of time, for example: 2 seconds

I've done a bunch of googling in the last hour and have found unanswered questions on stackoverflow. I do not see a function for pressing and holding the left mouse button in the docs

The docs describe an interval keyword argument to specify the amount of pause between the clicks in seconds. this is close to what i need but not exactly it. I'm looking for a keyword or function that extends the interval of the click itself, not the interval between clicks.

Someone has asked this same question here in this sub over a year ago but it was never correctly answered.

Here is some made up pseudocode of what I'm looking for:

pyautogui.moveTo(x, y)
pyautogui.clickAndHold(2) #this function does not exist but i passed 2 to it to #represent 2 seconds

# or this:
pyautogui.pressAndHold(button='left', 2) #again, i made up this function

so can someone please help me press and hold the left mouse button using pyautogui and then release it after an arbitrary number of seconds?

not sure if anyone cares but if I pull this off I can impress my boss so it would be pretty dope if I was able to do this.

thanks

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ mouse-keyboard-automation-using-python
Mouse and keyboard automation using Python - GeeksforGeeks
January 21, 2021 - import pyautogui as pg import time def delete_for_everyone(): pg.click(807, 979) pg.typewrite("hello") pg.typewrite(["enter"]) time.sleep(2) pg.click(1621, 896) pg.click(1621, 896) # time.sleep(1) pg.click(1693, 859) # time.sleep(1) pg.click(1014, 669) # time.sleep(1) pg.click(1111, 605) a=20 time.sleep(10) while(a!=0): delete_for_everyone() a=a-1
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ pyautogui click() and moveto() not working mac os bigsur
r/learnpython on Reddit: Pyautogui click() and moveTo() not working mac os bigsur
February 17, 2021 -

I've been trying to use the pyautogui library but when i try to use the move() the python launcher bounces on the dock then disappears and nothing happens, i don't even get any errors, I saw a post from a while back when catalina was around and the person who made the post ended up going back to an older OS X because they couldn't figure out a solution, i also found the problem on the github repo for pyautogui but the solution which was to add your terminal or python launcher or code editor to accessibility list in privacy didn't work for me. Below i'm providing my code, the github issue link and the other person's post, by the way i've done everything they said they've done. I'd really appreciate some help, thanks.

Is anyone else having PyAutoGUI issues after updating to Catalina?

pyautogui.click() almost seems to work. Clicks work in the window that I tell it to, but it's as if immediately after a click, the window focus returns to VS Code or Terminal. And then any pyautogui.typewrite, keyup, keydown, any of those keystroke commands are entered into VS Code or Terminal rather than the window I've had it click on to focus. Doing a command + tab doesn't do the trick either as those keys are entered into Terminal rather than acting as hotkeys on OSX.

I can't seem to keep the focus on the window I'm trying to operate on.

I've tried reverting from zsh back to bash. I've tried adding Terminal, zsh, bash, and VS Code in the Accessibility area of Security & Settings to give full keyboard and mouse control.

Apple does say that their depreciating Quartz (what pyautogui is built off of to operate OSX) in 10.15 (realized this one too little, too late). But that's supposed to mean it still works they just won't be updating it, right?

Anyone else experiencing this? I'm hoping for someone smarter than me who can guide me to a fix.

Thanks!

import os, sys, subprocess
import pyautogui 
import time

def open_file(filename):
    if sys.platform == "win32":
        os.startfile(filename)
    else:
        opener = "open" if sys.platform == "darwin" else "xdg-open"
        subprocess.call([opener, filename])

def runZoom():
     open_file("/Applications/zoom.us.app")
     joinbtn=pyautogui.locateCenterOnScreen("Join_Meeting.png", confidence=.5)
     pyautogui.moveTo(joinbtn)
     pyautogui.click()

runZoom()

Github issue link

๐ŸŒ
Internshala
internshala.com โ€บ home โ€บ fresher jobs โ€บ software development fresher jobs
129 Software Development Fresher Jobs in April (2026)
1 week ago - Apply for 129 software development fresher jobs on Internshala. Explore the latest software development job vacancies & openings for freshers across top companies.