Python-Mouse and keyboard operation with pyautogui

Introduction

Do you know that you can operate the mouse and keyboard automatically? With pyautogui, you can easily operate the mouse and keyboard.

Basics of pyautogui

moveTo The moveTo function is a function for moving the mouse pointer.

sample.py


pyautogui.moveTo(x coordinate,y coordinate)

click The click function is a function to click a specific position on the PC screen.

sample.py


pyautogui.click(x coordinate,y coordinate)

rightClick The rightClick function is a function to right-click a specific position on the PC.

sample.py


pyautogui.rightClick(x coordinate,y coordinate)

position The position function is a function to get the current mouse position.

sample.py


place=pyautogui.position()
print("x coordinate", place.x)
print("y coordinate", place.y)

typewrite The typewrite function is a function that inputs the passed character string character by character.

sample.py


pyautogui.typewrite("hello")

hotkey The hotkey function is a function for entering keys such as the Enter key (Return key) and the Alt key.

sample.py


pyautogui.hotkey("Return")
pyautogui.hotkey("Alt")

Finally

Have you become proficient in pyautogui? I hope so. I will continue to write many articles about Python. If you read this article and have any thoughts, please let us know in the comments.

Recommended Posts

Python-Mouse and keyboard operation with pyautogui
[Automation] Manipulate mouse and keyboard with Python
Japanese input with pyautogui
With and without WSGI
With me, cp, and Subprocess
Programming with Python and Tkinter
Encryption and decryption with Python
Working with tkinter and mouse
Python and hardware-Using RS232C with Python-
Try matrix operation with NumPy
S3 operation with python boto3
Django installation and operation check
Super-resolution with SRGAN and ESRGAN
group_by with sqlalchemy and sum
python with pyenv and venv
Get keyboard events with python
With me, NER and Flair
Works with Python and R
Solving with Ruby, Python and numpy AtCoder ABC054 B Matrix operation
How to use Python with Jw_cad (Part 2 Command explanation and operation)