python · 1月 18, 2023 0

PyAutoGUI: How to use the Python library to control your Keyboard

内容纲要

You can use the PyAutoGUI library to control Python.

pip install pyautogui

Type characters using the write() function.

You can use the write() function to type characters.

For example, the syntax below can be used to type.

import pyautogui
pyautogui.write('Hello There')

Run the code in Python, and you’ll get the phrase:

Hello There

You can take things further by adding a delay.

import pyautogui
pyautogui.write('Hello There', interval = 0.5)

After running the code, you notice the 0.5 seconds delay after each character.

%d 博主赞过: