安裝包
pip install pyautogui
pip install pyperclip
pyautogui
更多參考官網:https://github.com/asweigart/pyautogui
不支持中文輸入
from time import sleep
import pyautogui
# 正負數 表示向上或向下 數值越大滾動幅度越大
pyautogui.scroll(200) # 向上滾動
sleep(5)
pyautogui.scroll(-200) # 向下滾動
sleep(5)
# 鼠標移動位置 x表橫座標, y表示縱座標 單位像素, duration表示移動速度
pyautogui.moveTo(x=1300, y=250, duration=2)
sleep(5)
# 鼠標左擊一下 x表橫座標, y表示縱座標 單位像素, button=left 表示左鍵
pyautogui.click(x=738, y=223, button='left')
sleep(5)
# 發送英文字符,不支持中文字符
pyautogui.typewrite('hello world')
sleep(5)
# 啓動鍵盤熱鍵 粘貼功能
pyautogui.hotkey('ctrl', 'v')
pyperclip 解決中文輸入
pyperclip.paste() 這個提供的粘貼 測試不管用
import pyautogui
import pyperclip
pyperclip.copy('中文') # 先複製
pyautogui.hotkey('ctrl', 'v') # 再粘貼