Use pyautogui to operate the mouse and keyboard to enter text

There are two ways to input text using pyautogui:
Method 1: Use the typewrite function
pyautogui.typewrite('hello your words')
This method can only input English characters, and does not take care of the input of Chinese characters!
For example, the input text cannot be obtained when running pyautogui.typewrite('I am Chinese')!

Method 2:
1. Use the shortcut keys Ctrl+c and Ctrl+v
to click on the text and use the pyautogui.hotkey('Ctrl','c') method to copy, then find the place to be entered and call pyautogui.click() and then execute pyautogui.hotkey('Ctrl','v'), can realize copy text input!
2. Use pypaperclip to copy and paste
Install pypaperclip
pip install pypaperclip
After using pypaperclip.copy('Chinese and English hello'), the text will be placed in the paste version, and then use the shortcut key to paste!

insert image description here

Guess you like

Origin blog.csdn.net/weixin_42551921/article/details/122846980