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
7
votes
2 answers

How to simulate a mouse click and drag?

I want to simulate an event where I left click on the Windows desktop, I drag the mouse a little to create a Selection box to another point, and then keep holding the left button at that point for some time without the Selection box…
Erick Lopes
  • 71
  • 1
  • 1
  • 3
7
votes
1 answer

What is the hotkey for command in Pyautogui?

I am messing around with PyAutoGUI, and I am learning about the hotkey function. I want it to press Command+R, but I can't find the keyword (like control becomes ctrl). What is it? I am using Pycharm. I am fully aware that this would lead to a…
Nv7
  • 406
  • 6
  • 20
7
votes
2 answers

Pyautogui don't work in game window

I'm making some tests using Pyautogui on games. But in those games that change your cursor and fullscreen games, none of the methods work. I'm trying now on Ragnarok Online. I tried: pyautogui.click() pyautogui.moveTo(x, y,…
Cas
  • 336
  • 1
  • 3
  • 18
7
votes
5 answers

PyAutoGUI locate command returning incorrect coordinates for image recognition

I am trying to use pyautogui.locateCenterOnScreen() to find the exact point of an image on a screen, but whenever the coordinates are returned it seems to always be larger by a factor of two (i.e. gives (2026, 722) but actually is (1013, 361)). I am…
D.Vious
  • 93
  • 2
  • 6
6
votes
2 answers

How to fix 'TypeError: '<' not supported between instances of 'str' and 'int' when running pyautogui.locateOnScreen()?

im writing a program that would be able to detect the shiny sprite of whatever pokemon that im hunting, however, whenever i run pyautogui.locateOnScreen() i raise a TypeError: '<' not supported between instances of 'str' and 'int' import pyautogui…
6
votes
3 answers

"The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source"

I am trying to run a Python program with pyautogui but there's a problem because it is telling me that Pillow is not installed. I tried to install it or upgrade it with commands such as pip install Pillow --upgrade but nothing worked. On the…
Kyuujin
  • 71
  • 1
  • 5
6
votes
1 answer

Is there a way to get Pyautogui to search for an image from a url instead of local storage?

I'm building a simple program with Tkinter to be distributed based on Python Pyautogui that has to click on certaing png images. These images change every month so I'd like to have these on a web site where I update them every time they're needed so…
6
votes
2 answers

Press windows key with pyautogui or python

pyautogui has this functions such as pyautogui.press(key), but I can't figure out how to press the windows key, can someone help me in this situation? Thanks
Usual_Coder
  • 99
  • 1
  • 2
  • 6
6
votes
2 answers

Pyautogui on RDP

I am using pyautogui in Windows 10 with Python 3, in a virtual machine accessed by remote desktop. Unfortunately, the program stops execution when I close remote connection, giving "OSError: screen grab failed". I've searched for a solution online,…
Lore
  • 1,286
  • 1
  • 22
  • 57
6
votes
2 answers

Pyautogui - Need to hold shift and click

How does one hold shift and and click with the mouse using pyautogui? pyautogui.hotkey('shift', click(1611, 600)) have tried the line above. But it doesn't work
Gabriel Cesar
  • 327
  • 2
  • 4
  • 10
6
votes
2 answers

Pyautogui screenshot. Where does it go? How to save and find later?

I am learning from Al Sweigart's you tube video for automating the boring stuff. I got to the part of taking screenshots. He didn't really explain in his video so I tested things out. I found that it takes screenshots of the whole desktop but I…
Trevor Trinh
  • 75
  • 1
  • 1
  • 5
6
votes
2 answers

Python simulating 'enter' keypress in a game

So I've been attempting to get a script to type out a string of text in a video game (Guild Wars 2). Mainly I'm using pyautogui and for the most part it works fine. My issue is it seems I can't get the game to recognize 'enter'. For example if I…
Ronan
  • 407
  • 3
  • 5
  • 13
6
votes
0 answers

conflict between tkinter and pyautogui?

I am seeing a conflict between pyautogui and tkinter. When I run a program without tkinter, pyautogui can control the keyboard & mouse as expected. However, if I first get input (e.g. a user-selected directory) through tkinter, I get this…
user3450049
  • 825
  • 1
  • 10
  • 20
6
votes
4 answers

pip3 install pyautogui fails with error code 1 Mac OS

I tried installing the autogui python extension: pip3 install pyautogui And this installation attempt results in the following error message: Collecting pyautogui Using cached PyAutoGUI-0.9.33.zip Complete output from command python setup.py…
Timo Krall
  • 147
  • 2
  • 12
6
votes
1 answer

How can I send text when the window is minimized?

I have tried using python libraries: pyautogui + pwinauto. But to no avail. Once the window is minimized the text is no longer send. code snippet: import pyautogui import…
george
  • 685
  • 2
  • 9
  • 22