DEV Community

Cover image for GUI automation with Pyautogui
Anja
Anja

Posted on

GUI automation with Pyautogui

Good evening! Do you already know the pyautogui Module? Its a python module that can send virtual keypresses and mouse clicks to your Operating System. Depending on your OS you might have to install different dependencies. For Linux you need to run:

sudo pip3 install python3-xlib
sudo apt-get install scrot 
python3-tk python3-dev
Enter fullscreen mode Exit fullscreen mode

Then you can run pip3 install pyautogui. If your program somehow gets out of control on Linux you can Logout with Ctrl-Alt-Del. Also you can include short pauses into your program so you gain back control of the mouse or keyboard. For the mouse movements you make use of the x and y-coordinates of your screen.

Here are some functions of the PyAutoGUI:

  1. moveTo(x,y)
  2. click(x,y,button)
  3. rightClick()
  4. scroll(units)
  5. press(key)

I also created a video about it here:
Alt Text

Read more about the PyAutoGUI here:

https://automatetheboringstuff.com/2e/chapter20/

What kind of automation tools or frameworks have you already been using? I love automating stuff. :D Have a nice evening!

Top comments (0)