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.
1131 questions
21
votes
7 answers

pyautogui.locateCenterOnScreen() returns None instead of coordinates

import pyautogui print (pyautogui.locateCenterOnScreen("C:\Users\Venkatesh_J\PycharmProjects\mouse_event\mouse_event.png")) Instead of returning coordinates, it returns None.
Venkatesh J
  • 211
  • 1
  • 2
  • 7
19
votes
3 answers

Pyautogui: Mouse Movement with bezier curve

I'm trying to move the mouse in a bezier curve motion in Pyautogui to simulate more of a human movement as seen here: There is some tweening / easing functions within pyautogui but none of which represent a bezier curve type movement. I created a…
ahinkle
  • 1,363
  • 1
  • 17
  • 41
13
votes
2 answers

How can I invert the cursor movement in python?

In this code, I'm using Python 2.7.13, OpenCV 2.4.13 and PyAutoGUI 0.9.36. The objective is to move the cursor according to the facial movement, but the cursor movement is inverted. For example, if my face goes to right, the cursor moves to left and…
TigerC
  • 151
  • 6
13
votes
11 answers

Why PyAutoGui LocateOnScreen() only Returns None

Here's the code that I'm trying to run: import pyautogui r=pyautogui.locateOnScreen('C:\Users\David\Desktop\index.png',grayscale=False) print r
Raheem
  • 157
  • 1
  • 1
  • 6
13
votes
5 answers

import error for pyautogui

I installed the pyautogui module and dependencies via pip-3.2 on my raspi correctly, However when I am trying to do import pyautogui I am getting an import error: ImportError: No module named pyautogui What am I doing wrong? Did the command…
Nixxon
  • 133
  • 1
  • 1
  • 8
12
votes
3 answers

Input unicode string with pyautogui

I'm creating an autotesting app with pyautogui lib. I want to use typewrite method to input text into forms. But some of my input strings have unicode characters in them. For example: Næst According to documentation typewrite can only press…
testlnord
  • 390
  • 4
  • 14
11
votes
5 answers

Copy highlighted text to clipboard, then use the clipboard to append it to a list

I'm trying to automate some actions in a browser or a word processor with pyautogui module for Python 3 (Windows 10). There is a highlighted text in a browser. text the following script should print the highlighted text import pyautogui as pya #…
10
votes
2 answers

Can pyautogui be used to prevent windows screen lock?

I tried to use this script to prevent windows screen lock. The script works for moving the mouse, but it doesn't prevent windows 10 from locking. import pyautogui import time import win32gui, win32con import os Minimize =…
Python account
  • 172
  • 2
  • 10
10
votes
3 answers

Pyautogui mouse clicks without actually moving the mouse

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 script is running as the cursor moves around the screen.…
Gabriel Cesar
  • 197
  • 1
  • 3
  • 10
10
votes
3 answers

Python pyautogui window handle

Using pyautogui is there a way to get a handle to a window so that I can ensure that a click is performed on that window only? In other words, if my window isn't in focus, then the click does not occur. Additionally, if my window isn't in focus then…
kronosjt
  • 393
  • 3
  • 6
  • 21
10
votes
1 answer

How I can attach the mouse movement (pyautogui) to pyvirtualdisplay with selenium webdriver (python)?

I am trying to automatize a website how have a SWF inside. I cant move the mouse with selenium, because is a SWF,so to fix this I use the pyautogui library. Everything works fine!, but! when I use pyvirtualdisplay to hide the navigator the mouse is…
nguaman
  • 783
  • 1
  • 7
  • 19
9
votes
2 answers

How to print out 'Live' mouse position coordinates using pyautogui?

I used lots of different source codes, and even copied and pasted but I keep getting random symbols that shift when i move my mouse over them here is my code... import pyautogui, time, sys print('Press Ctrl-C to quit.') try: while True: …
SovietStormSam
  • 103
  • 1
  • 1
  • 5
8
votes
1 answer

Pyautogui does not move the actual mouse pointer

I've been having a problem with pyautogui. Anytime I use the functions, it works, but it uses an "invisible" mouse pointer. Basically the module doesn't use the mouse to click things, but they still click and drag. Here's a visual example: Reading…
ExecutionByFork
  • 216
  • 2
  • 17
8
votes
1 answer

Speeding up pyautogui screenshot() with region

I'm trying to speed up the screenshot function in pyautogui since I only need a small portion of the screen. The region variable is supposedly the way to this a.k.a. pyautogui.screenshot(region=(0,0,400,300)). However after doing some testing I…
8
votes
1 answer

How to increase number of clicks per second with pyautogui?

I am developing a bot for timed mouse clicking game. I am using pyautogui. The aim is to click most times on a button in a minute. My code is: import pyautogui, time time.sleep(5) while True: pyautogui.click() The infinite loop is not the…
L_Pav
  • 271
  • 2
  • 11
1
2 3
75 76