pyautogui | platform GUI automation Python module for human beings | Automation library

 by   asweigart Python Version: 0.9.54 License: BSD-3-Clause

kandi X-RAY | pyautogui Summary

kandi X-RAY | pyautogui Summary

pyautogui is a Python library typically used in Automation applications. pyautogui has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install pyautogui' or download it from GitHub, PyPI.

PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. Full documentation available at Simplified Chinese documentation available at Source code available at If you need help installing Python, visit
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pyautogui has a highly active ecosystem.
              It has 8215 star(s) with 1078 fork(s). There are 184 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 414 open issues and 223 have been closed. On average issues are closed in 236 days. There are 44 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of pyautogui is 0.9.54

            kandi-Quality Quality

              pyautogui has 0 bugs and 0 code smells.

            kandi-Security Security

              pyautogui has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pyautogui code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pyautogui is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pyautogui releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              pyautogui saves you 1199 person hours of effort in developing the same functionality from scratch.
              It has 2714 lines of code, 158 functions and 9 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pyautogui and discovered the below as its top functions. This is intended to give you an instant insight into pyautogui implemented functionality, and help decide if they suit your requirements.
            • Run a command
            • Logs a screenshot of a function
            • Performs a click
            • Run command list
            • Handle key down
            • Create a custom key event
            • Create a special key event
            • Click a left click
            • Send a click event
            • Performs horizontal scroll
            • Handles mouse events
            • Display the mouse position
            • Checks if the given coordinates are on the screen
            • Writes the given message to the console
            • Makes the mouse move operation
            • Performs a right click
            • V scroll events
            • Horizontally horizontal scroll
            • Performs a middle click
            • Context manager
            • Handles key down
            • Double click
            • Handles key down events
            • Hides key up
            • Generic function decorator
            • Prints a message to stdout
            Get all kandi verified functions for this library.

            pyautogui Key Features

            No Key Features are available at this moment for pyautogui.

            pyautogui Examples and Code Snippets

            pyautogui.locateAllOnScreen can't locate the image
            Pythondot img1Lines of Code : 15dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pyautogui
            
            onigiri = pyautogui.locateAllOnScreen('onigiri.png', confidence=0.9)
            
            for item in onigiri:
                print(item)
            
            Box(left=849, top=400, width=55, height=53)
            Box(left=988, top=400, width=55, height=53)
            <
            in swap array[i] = array[j] TypeError: 'tuple' object does not support item assignment
            Pythondot img2Lines of Code : 4dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            def swap(array, i, j):
                array[i], array[j] = array[j], array[i]
                return array
            
            in swap array[i] = array[j] TypeError: 'tuple' object does not support item assignment
            Pythondot img3Lines of Code : 31dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            lst = [1, 2, 3, 4]
            
            def alter_mutable(obj):
                del obj[0]
            
            print(lst)
            alter_mutable(lst)
            print(lst)
            
            [1, 2, 3, 4]
            [2, 3, 4]
            
            num = 2
            
            def alter_immutable(obj):
                obj += 1
            
            print(num)
            alter
            Add 1 hour to time from user input
            Pythondot img4Lines of Code : 5dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Time_inp = int(input("Enter a time (+1hour will be added to it): "))
            Time_inp = datetime.strptime(Time_inp , '%H%H:%M%M')
            Time_inp = Time_inp + timedelta(hours=1)
            Time_inp = Time_inp.strftime('%H%m')
            
            How do I make my python-kivy window become the focus when the mouse cursor is over the window?
            Pythondot img5Lines of Code : 71dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import kivy
            from kivy.uix.widget import Widget
            from kivy.app import App
            from kivy.clock import Clock
            from kivy.core.window import Window
            
            import pyautogui  # for mouse click
            
            kivy.lang.Builder.load_string("""
            #:kivy 2.0.0
            
            :
                
                Scrol
            Check color value of pixel on screen
            Pythondot img6Lines of Code : 12dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pyautogui
            
            def getColorUnderMouse():
                x, y= pyautogui.position()
                pixel = pyautogui.screenshot(
                    region=(
                        x, y, 1, 1
                    )
                )
                return pixel.getcolors()
            
            
            No module named "pyautogui" after using pip install and it appearing on pip freeze
            Pythondot img7Lines of Code : 6dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            $ python
            
            >>> import pyautogui
            
            $ python -m pip install pyautogui
            
            Runtime error when trying to spawn multiple processes (image detection and print to terminal)
            Pythondot img8Lines of Code : 64dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from threading import Thread
            from time import sleep
            
            def run_close_window_task():
                while True:
                    print("Hello, close window task is running!")
                    sleep(2)
            
            t = Thread(name='backgroundtask', target=run_close_window_task)
            t.sta
            Open and save a PDF file using Acrobat Reader in the background using Python
            Pythondot img9Lines of Code : 13dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import os
            os.startfile(path)
            filename = os.path.basename(path)
            focus = pg.getWindowsWithTitle(filename)
            while len(focus) == 0:
                focus = pg.getWindowsWithTitle(filename)
            focus [0].show() # show() for python3.9, activate() for python3.7
            t
            Canvas.create_image(), draggable image seems not to be moving from its place?
            Pythondot img10Lines of Code : 43dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                    c.tag_bind(btn,btn,on_drag_start)
                    c.tag_bind(motion,motion,on_drag_motion)
            
                    c.tag_bind(widget, btn, on_drag_start)
                    c.tag_bind(widget, motion, on_drag_motion)
            

            Community Discussions

            QUESTION

            How do I find an image on screen ignoring transparent pixels
            Asked 2022-Mar-25 at 22:56

            I have a png of an asset, say:

            and I'm trying to find it on my screen which looks something like:

            Normally, I would use pyautoGUI as such:

            ...

            ANSWER

            Answered 2022-Mar-01 at 12:41

            In OpenCV, matchTemplate() has a masked mode. So you basically read the transparent template image as is and then extract its base image and the alpha channel. The alpha channel is used as the mask in matchTemplate(). See https://docs.opencv.org/4.1.1/df/dfb/group__imgproc__object.html#ga586ebfb0a7fb604b35a23d85391329be

            Input:

            Template:

            Source https://stackoverflow.com/questions/71302061

            QUESTION

            Canvas.create_image(), draggable image seems not to be moving from its place?
            Asked 2022-Mar-24 at 02:39

            Im working with Tkinter currently and im trying to make an draggable canvas image, the code i've "made"/edited from another stack overflow question, the second one to be particular. There code works for me when im using tk.Frame(), but it gives an error for Canvas.create_image(). So i edited it a little but now it seems to to be moving the image at all when i drag it

            My code:

            ...

            ANSWER

            Answered 2022-Mar-24 at 02:39

            There are few issues inside make_draggable() function:

            • first argument of .tag_bind() is the item ID of a canvas item. For your case, it is widget argument of make_draggable(). So the following lines:

            Source https://stackoverflow.com/questions/71595667

            QUESTION

            Break out of a for loop nested in a while loop when while loop's condition becomes False
            Asked 2022-Mar-24 at 00:25

            I have a while loop that iterates for 8 seconds, and inside it is a for loop which iterates 4 times, each time executing some pyautogui press functions. However, when my loop breaks, the for loop within continues until completion. Code:

            ...

            ANSWER

            Answered 2022-Mar-23 at 23:39

            Well, your description doesn't reflect reality. The "for" loop certainly will end with the "while" loop, but you can't interrupt the "for" loop in the middle. If you want to stop in mid-keystroke, then you'll need to check the time at every keystroke:

            Source https://stackoverflow.com/questions/71591817

            QUESTION

            getting 'int' object is not iterable error
            Asked 2022-Mar-20 at 07:13

            i made a code and wanted that it types numbers from 12300 to 13000 but i got this error

            ...

            ANSWER

            Answered 2022-Mar-20 at 07:13

            On line 12, instead of writing keyboard.write(numb), write keyboard.write(str(numb)). This changes numb which is an int type to a str type before writing it.

            Source https://stackoverflow.com/questions/71544382

            QUESTION

            How to simulate key press in a specific chrome tab\window
            Asked 2022-Mar-16 at 01:38

            So I want to simulate key presses in a SPECIFIC window\chrome tab. For eg, with pyautogui:

            ...

            ANSWER

            Answered 2022-Mar-16 at 01:38

            Unfortunately, PyAutoGUI can't do this because it only blindly clicks on the screen at x, y coordinates. Unless you know the coordinates of the tab, you won't be able to put it in focus and send key presses to the window.

            I recommend a library like Selenium for doing GUI automation in web browsers.

            Source https://stackoverflow.com/questions/71489508

            QUESTION

            How do I get the screen / display resolution?
            Asked 2022-Mar-07 at 09:24

            I am currently working on a game in Rust (Piston Crate) and I want to center the Window it creates. It allows me to change the window's offset from the top left of the screen. I want to get the resolution the operating system works in (screen / display / monitor resolution) and center the window based on that.

            In Python for example, by using pyautogui, you can get the screen resolution using pyautogui.size().

            In Java, by using java.awt, you can get the screen resolution using Toolkit.getDefaultToolkit().getScreenSize().

            Is there something similar in Rust I could use? (std- or any extern crate)

            ...

            ANSWER

            Answered 2022-Mar-06 at 19:44

            I depends of the backend you use. For example if you use the Winit / Glutin backend you can use the MonitorHandle struct, which has a size() method.

            Docs:https://docs.rs/winit/0.26.1/winit/monitor/struct.MonitorHandle.html

            or for Glutin https://docs.rs/glutin/0.28.0/glutin/window/struct.Window.html#method.available_monitors

            The Glutin module also has a dpi module that can provide information. https://docs.rs/glutin/0.28.0/glutin/dpi/index.html

            If you use SDL2 backend, you could take a look at the sdl2_sys module SDL_HINT_RENDER_LOGICAL_SIZE https://docs.rs/sdl2-sys/0.35.2/sdl2_sys/constant.SDL_HINT_RENDER_LOGICAL_SIZE_MODE.html

            Source https://stackoverflow.com/questions/71371940

            QUESTION

            Why do I keep getting a Runtime Error with this script?
            Asked 2022-Mar-05 at 16:52

            I realise that I am presupposing it is the if__name__ == '__main__' statement that will fix my problem, but after searching this site this seems to be a likely answer...

            My script is designed to login to a Gmail account, open specific emails and click on a certain link. The script should then wait about 15 seconds, before closing the new window, and then move onto the next email.

            However, when I try to run the script it gets stuck with a Runtime Error.

            I will post the script and then the error message below it. Any help would be greatly appreciated, because I am completely stuck.

            ...

            ANSWER

            Answered 2022-Mar-05 at 16:52

            It seems to be a Windows/Mac specific issue, check out this answer

            It has to do with the way the multiprocessing module starts processes on those platforms. Basically you should not start processes outside the __main__ context.

            So try to move any process creation into the main block as shown below:

            Source https://stackoverflow.com/questions/71361888

            QUESTION

            Is there anything similar to PyAutoGUI for NodeJS that can try to locate an image inside a screen capture?
            Asked 2022-Mar-03 at 06:01

            I am trying to code a bot to automate some tasks on a videogame with JS and Node, so far I've been using RobotJS. The problem I'm facing is that I need to find something on the screen as it moves from time to time to then click on it. Something similar to PyAutoGUI locateOnScreen() function.

            It needs to use AI to have some tolerance too, as the image will not be exactly the same from time to time, though it's almost the same so I think any basic AI for image recognition would detect it fine.

            Does anyone have an idea on what to use for this specific case?

            ...

            ANSWER

            Answered 2022-Mar-03 at 06:01

            Try this package called node-moving-things-tracker. I have been using it reliably for a while. It is being actively maintained. Data outputs are well-organized and interpretable. There are a few examples here: https://www.npmjs.com/package/node-moving-things-tracker

            Source https://stackoverflow.com/questions/71078359

            QUESTION

            Record Mouse and Keyboard Movements into TXT file - Python
            Asked 2022-Mar-01 at 18:59

            I am interested to see if there is a way to store mouse and keyboard movements to automate some repetitive tasks.

            Right now, I am able to send mouse and keyboard movements using pyautogui like this:

            ...

            ANSWER

            Answered 2022-Mar-01 at 18:59

            If I understood correctly, you want a log of actions in a txt file to be then read and reproduced by pyautogui.

            There are many libraries for that like pynput that offer simple listeners to actions like mouse clicks, keyboard inputs... like so:

            Source https://stackoverflow.com/questions/71311312

            QUESTION

            cv2 creates a unreadable .mp4v (and .avi) file
            Asked 2022-Feb-26 at 11:41

            I'm trying to create a simple screen recorder with Python. This is the code

            ...

            ANSWER

            Answered 2022-Feb-24 at 22:23

            There are several implementation issues:

            • As far "output.mp4v" is not a valid mp4 file extension in the current context.
              Change the file name to "output.mp4"
            • "MP4V" is case sensitive and suppposed to be "mp4v".
            • As gerda commented, the frame size may not be 1920x1080.
            • The else:, break at the end of the loop may break the loop after one frame.
            • cv2.waitKey is not working without using cv2.imshow (without an open windows).
              The loop is not terminated when q is pressed.
              The code may never reach to out.release().

            Based on the following post, I tried to create a portable code that waits for Esc key, without root privilege in Linux.
            The solution I found (waiting for Esc) seem a bit complicated... You may try other solutions.

            Code sample:

            Source https://stackoverflow.com/questions/71256074

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pyautogui

            You can install using 'pip install pyautogui' or download it from GitHub, PyPI.
            You can use pyautogui like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install PyAutoGUI

          • CLONE
          • HTTPS

            https://github.com/asweigart/pyautogui.git

          • CLI

            gh repo clone asweigart/pyautogui

          • sshUrl

            git@github.com:asweigart/pyautogui.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link