Questions tagged [pyautogui]

PyAutoGUI is a cross-platform GUI automation Python module used to programmatically control the mouse and keyboard.

Official document.

PyAutoGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications. The API is designed to be as simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3.

PyAutoGUI has several features:

  • Moving the mouse and clicking or typing in the windows of other applications.
  • Sending keystrokes to applications (for example, to fill out forms).
  • Take screenshots, and given an image (for example, of a button or checkbox), find it on the screen.
  • Locate an application’s window, and move, resize, maximize, minimize, or close it (Windows-only, currently) Display message boxes for user interaction while your GUI automation script runs.
1828 questions
5
votes
4 answers

Pyautogui error: The Pillow package is required to use this function

My pyautogui program gives me the following error when I do: position = pyautogui.locateCenterOnScreen(image, confidence=.7) Error message: File "C:\Users\ashis\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line…
user18155594
5
votes
2 answers

NameError: ObjC Class 'b'NSEvent'' couldn't be found. - PyAutoGui

I installed pyautogui recently, using pip3 install pyautogui. This worked and I received no error on installation. But when importing the module as shown below. import pyautogui I was kindly greeted with this error message. Traceback (most recent…
Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
5
votes
2 answers

What is the purpose of the pyautogui failsafe?

So, I was just messing around with pyautogui moving the mouse to random positions on the screen, when I manually moved the mouse to the top left corner of the screen and ran the program, it raised a pyautogui failsafe. I do know how to disable it…
Coder9390
  • 163
  • 1
  • 1
  • 9
5
votes
2 answers

What's the difference between the write() and typewrite() functions in pyautogui?

I've seen the use of pyautogui.typewrite() but I can't find the documentation for it in the pyautogui docs. I did find the pyautogui.write() function in the docs and I wanted to know if they are the same thing, because from what I can see, they seem…
Ben Dover
  • 153
  • 1
  • 7
5
votes
2 answers

Python - Turtle recreating image too slow

I got curious and wondered if I could have the pyautogui module detect the color from every few pixels from an image and have turtle recreate them in it's canvas using small circles. I ended up finding a way to make it work, and I liked how the…
5
votes
1 answer

Python - Human Like Mouse Behaviour

I'm trying to simulate human-like mouse movements using pyautogui or autopy Do any of you know or can provide a good way? Let's say I want to move from (0, 0) to (56, 200). If I use the pyautogui.moveTo(), It just jumps there. If I use the…
SunAwtCanvas
  • 1,261
  • 1
  • 13
  • 38
5
votes
4 answers

Locate color position on screen?

I want to click on a specific color on the screen with pyautogui, but for that I need its position, and I can't find any useful information about the topic. I'm trying to make a Piano Tiles autoclicker and for that I've thought about identifying the…
Prensapjaimo
  • 67
  • 1
  • 1
  • 6
5
votes
1 answer

Python: pyautogui mouse movement in Thread is slow and unreliable

I am attempting to automate some mouse movement to a certain position in Python 3. For this, I am using a module pyclicker, specifically the HumanClickerclass from the module. It uses an algorithm to calculate a 'human-like' flow of points to the…
willeum
  • 53
  • 1
  • 4
5
votes
3 answers

How to simulate a mouse click while holding the SHIFT key in Windows?

Hello I'm trying to simulate a mouse click while holding the SHIFT key. I have been trying to do this with the pynput module. This is my code so far: from pynput.keyboard import Key from pynput.keyboard import Controller as Cont from pynput.mouse…
teller.py3
  • 822
  • 8
  • 22
5
votes
1 answer

typewrite(),press() on pyautogui is not working on Remote Desktop

I am using my host where i used to connect to the Remote machine where i want to fetch some data. I am using pyautogui for press operation and typewrite() to enter some values. The remote server is configured and application i want to operate will…
user3664681
  • 171
  • 1
  • 3
  • 13
5
votes
2 answers

Unable to install pyautogui

I'm trying to install Pyautogui on ubuntu 18.04, but I keep receiving the following error message: $pip3 install pyautogui Collecting pyautogui Using cached…
user10106415
5
votes
2 answers

PyAutoGui - Press key for X seconds

I'm currently working on a script that presses the 'w,a,s,d' keys in order to move a character in any game. For this to work, i need to have the 'w' key pressed for a specific amount of time. How can I achieve this? I thought of something…
Robin Kühn
  • 53
  • 1
  • 1
  • 4
5
votes
3 answers

pyautogui.press() causing lag when called

I have been working on a project where I need to call pyautogui.press('space'), however, when this is called, there is a noticable amount of lag. I need to try and keep the code running fairly fast because OpenCV is being used. If anyone knows how I…
bobtheguy
  • 51
  • 1
  • 3
5
votes
4 answers

How to trigger a Windows and L key Python-hotkey?

I am trying to run this code in Python. import pyautogui pyautogui.hotkey('win', 'l') So that when I run it it will trigger switch user in Windows but all it does is press l when I need it to press Win+l
Craftx398
  • 341
  • 1
  • 2
  • 13
5
votes
1 answer

using mouse with pyautogui on extended screens [python]

I am using python to move the cursor along multiple screens (using extended display). The method pyautogui.moveTo(_row_, _col_) moves the cursor to the correct position on the main screen, but does not move it outside of it. In windows "Personalize"…
Gal Sela
  • 51
  • 1
  • 3