pyautogui-automation
4
总安装量
4
周安装量
#48353
全站排名
安装命令
npx skills add https://github.com/steelan9199/wechat-publisher --skill pyautogui-automation
Agent 安装分布
opencode
4
gemini-cli
4
github-copilot
4
codex
4
kimi-cli
4
amp
4
Skill 文档
PyAutoGUI èªå¨åæä½
åè½æ¦è§
| åè½ç±»å« | æ¯æçæä½ |
|---|---|
| æªå¾ | å ¨å±æªå¾ãåºåæªå¾ãæªå¾å°åªè´´æ¿ |
| é¼ æ æ§å¶ | ç¹å»ãåå»ãç§»å¨ãç¸å¯¹ç§»å¨ãææ½ãæ»å¨ãæä¸/éæ¾ |
| é¢è²æä½ | è·ååç´ é¢è²ãæ¥æ¾é¢è²ä½ç½® |
| é®çæä½ | è¾å ¥ææ¬ãæé®ãç»åé®ãå¿«æ·æä½ï¼å¤å¶/ç²è´´/å ¨éçï¼ |
| å¾åè¯å« | å¨å±å¹ä¸æ¥æ¾å¾çä½ç½®ãçå¾ å¾çåºç°/æ¶å¤± |
| å¯¹è¯æ¡ | è¦åã确认ãè¾å ¥å¯¹è¯æ¡ |
| ç³»ç»ä¿¡æ¯ | å±å¹å辨çãé¼ æ ä½ç½®ãçªå£ä¿¡æ¯ |
| å·¥å · | çå¾ ãæå |
å¿«éå¼å§
åºæ¬ä½¿ç¨æ¨¡å¼
python scripts/automation.py <action> [åæ°...]
æææä½è¿å JSON æ ¼å¼ç»æã
èæ¬ä½ç½®: scripts/automation.py
æä½è¯¦è§£
æªå¾
# å
¨å±æªå¾ï¼èªå¨çææä»¶åï¼
python scripts/automation.py screenshot
# æå®è¾åºè·¯å¾
python scripts/automation.py screenshot --output my_screenshot.png
# åºåæªå¾
python scripts/automation.py screenshot --output region.png --region 100,100,400,300
# æªå¾å°åªè´´æ¿ï¼éè¦å®è£
pywin32ï¼
python scripts/automation.py screenshot_to_clipboard
python scripts/automation.py screenshot_to_clipboard --region 100,100,400,300
é¼ æ ç¹å»
# å·¦é®åå»åæ (100, 200)
python scripts/automation.py click --x 100 --y 200
# å³é®åå»
python scripts/automation.py click --x 100 --y 200 --button right --clicks 2
# å¿«æ·åå»
python scripts/automation.py double_click --x 100 --y 200
é¢è²æä½
# è·åæå®åæ çé¢è²
python scripts/automation.py get_pixel_color --x 100 --y 200
# è¿å: {"rgb": [255, 255, 255], "hex": "#ffffff"}
# æ¥æ¾é¢è²ä½ç½®ï¼ç²¾ç¡®å¹é
ï¼
python scripts/automation.py find_color --rgb 255,255,255
# æ¥æ¾é¢è²ï¼å¸¦å®¹å·®ï¼
python scripts/automation.py find_color --rgb 255,255,255 --tolerance 10
# 卿å®åºåæ¥æ¾
python scripts/automation.py find_color --rgb 255,0,0 --region 0,0,800,600
é¼ æ æ§å¶
# è·åå½åé¼ æ ä½ç½®
python scripts/automation.py get_mouse_position
# ç§»å¨é¼ æ ï¼ç¬é´ï¼
python scripts/automation.py move_mouse --x 500 --y 300
# ç§»å¨é¼ æ ï¼å¨ç»ææï¼0.5ç§ï¼
python scripts/automation.py move_mouse --x 500 --y 300 --duration 0.5
# ç¸å¯¹å½åä½ç½®ç§»å¨é¼ æ
python scripts/automation.py move_mouse_rel --x 100 --y -50
python scripts/automation.py move_mouse_rel --x 100 --y -50 --duration 0.5
# ææ½é¼ æ
python scripts/automation.py drag_mouse --x 800 --y 600 --duration 1.0
# é¼ æ æä¸ï¼ä¸éæ¾ï¼
python scripts/automation.py mouse_down --button left
# é¼ æ éæ¾
python scripts/automation.py mouse_up --button left
# æ»å¨ï¼æ£æ°åä¸ï¼è´æ°åä¸ï¼
python scripts/automation.py scroll --amount 500
python scripts/automation.py scroll --amount -500 --x 500 --y 300
å±å¹ä¿¡æ¯
# è·åå±å¹å辨ç
python scripts/automation.py get_screen_size
# è¿å: {"width": 1920, "height": 1080}
# è·åå½åæ´»å¨çªå£ä¿¡æ¯ï¼éè¦å®è£
pywin32ï¼
python scripts/automation.py get_active_window
# è¿å: {"title": "çªå£æ é¢", "left": 100, "top": 100, "width": 800, "height": 600}
# è·åææå¯è§çªå£å表ï¼éè¦å®è£
pywin32ï¼
python scripts/automation.py get_all_windows
# è¿å: {"count": 5, "windows": [...]}
çå¾
# çå¾
2 ç§
python scripts/automation.py sleep --seconds 2
é®çæä½
# è¾å
¥ææ¬
python scripts/automation.py type_text --text "Hello World"
# è¾å
¥ææ¬ï¼å¸¦é´éï¼
python scripts/automation.py type_text --text "Hello" --interval 0.1
# æä¸æé®
python scripts/automation.py press_key --key enter
python scripts/automation.py press_key --key esc
# ç»åé®
python scripts/automation.py hotkey --keys ctrl,c
python scripts/automation.py hotkey --keys ctrl,shift,esc
# å¿«æ·æä½
python scripts/automation.py copy # Ctrl+C
python scripts/automation.py paste # Ctrl+V
python scripts/automation.py cut # Ctrl+X
python scripts/automation.py select_all # Ctrl+A
python scripts/automation.py undo # Ctrl+Z
python scripts/automation.py redo # Ctrl+Y
python scripts/automation.py save # Ctrl+S
å¸¸ç¨æé®åç§°: enter, esc, tab, space, backspace, delete, up, down, left, right, f1–f12, ctrl, alt, shift, win
å¾åè¯å«
éè¦å®è£ opencv-python ä»¥ä½¿ç¨ confidence åæ°ï¼
# æ¥æ¾å¾çä½ç½®
python scripts/automation.py locate_on_screen --image button.png
# 使ç¨ç½®ä¿¡åº¦ï¼éè¦ opencv-pythonï¼
python scripts/automation.py locate_on_screen --image button.png --confidence 0.9
# 卿å®åºåæ¥æ¾
python scripts/automation.py locate_on_screen --image button.png --region 0,0,800,600
# æ¥æ¾ææå¹é
ä½ç½®
python scripts/automation.py locate_all_on_screen --image icon.png
# çå¾
å¾çåºç°ï¼æå¤çå¾
10ç§ï¼
python scripts/automation.py wait_for_image --image button.png --timeout 10
# çå¾
å¾çåºç°ï¼èªå®ä¹æ£æ¥é´éï¼
python scripts/automation.py wait_for_image --image loading.png --timeout 30 --wait_interval 1
# çå¾
å¾çæ¶å¤±
python scripts/automation.py wait_for_image_to_vanish --image loading.png --timeout 30
å¯¹è¯æ¡
# è¦åå¯¹è¯æ¡
python scripts/automation.py alert --title "æç¤º" --text "æä½å®æ"
# ç¡®è®¤å¯¹è¯æ¡
python scripts/automation.py confirm --title "确认" --text "æ¯å¦ç»§ç»ï¼"
# èªå®ä¹æé®
python scripts/automation.py confirm --title "éæ©" --text "è¯·éæ©æä½" --buttons "ä¿å,ä¸ä¿å,åæ¶"
# è¾å
¥å¯¹è¯æ¡
python scripts/automation.py prompt --title "è¾å
¥" --text "请è¾å
¥åç§°:" --default "é»è®¤å¼"
å®å ¨è®¾ç½®
èæ¬å·²å¯ç¨ä»¥ä¸å®å ¨ä¿æ¤ï¼
- FAILSAFE: å°é¼ æ å¿«éç§»å¨å°å±å¹å·¦ä¸è§ä¼è§¦åå¼å¸¸åæ¢
- PAUSE: æ¯ä¸ªæä½åæ 0.1 ç§é»è®¤æå
宿´ç¤ºä¾
èªå¨åç»å½æµç¨
# 1. æªå¾è®°å½åå§ç¶æ
python scripts/automation.py screenshot --output login_start.png
# 2. ç¹å»ç¨æ·åè¾å
¥æ¡
python scripts/automation.py click --x 500 --y 300
# 3. è¾å
¥ç¨æ·å
python scripts/automation.py type_text --text "myusername"
# 4. æ Tab 忢å°å¯ç æ¡
python scripts/automation.py press_key --key tab
# 5. è¾å
¥å¯ç
python scripts/automation.py type_text --text "mypassword"
# 6. ç¹å»ç»å½æé®
python scripts/automation.py click --x 500 --y 400
# 7. çå¾
页é¢å è½½
python scripts/automation.py sleep --seconds 3
# 8. æªå¾è®°å½ç»æ
python scripts/automation.py screenshot --output login_end.png
é¢è²æ£æµèªå¨å
# æ£æµç¹å®ä½ç½®é¢è²å¹¶æ§è¡æä½
color=$(python scripts/automation.py get_pixel_color --x 100 --y 100)
# è§£æ JSON 夿é¢è²åæ§è¡ç¸åºæä½
å¾åå®ä½ç¹å»
# æ¥æ¾æé®å¹¶ç¹å»
result=$(python scripts/automation.py locate_on_screen --image submit_button.png --confidence 0.9)
# ä»ç»æä¸æå center_x, center_y å¹¶ç¹å»
ä¾èµå®è£
èæ¬ä¼èªå¨å®è£ å¿ éçä¾èµï¼
pyautogui: æ ¸å¿èªå¨ååºpillow: å¾åå¤ç
å¯éä¾èµï¼ç¨äºå¾åè¯å«ç½®ä¿¡åº¦ï¼ï¼
pip install opencv-python
èµæºç´¢å¼
- automation.py – ä¸»å ¥å£èæ¬
- utils.py – å ¬å ±å·¥å ·å½æ°
- mouse.py – é¼ æ æä½
- keyboard.py – é®çæä½
- screen.py – æªå¾åå¾åè¯å«
- color.py – é¢è²æ£æµ
- dialog.py – å¯¹è¯æ¡æä½
- system.py – ç³»ç»ä¿¡æ¯
注æäºé¡¹
- åæ ç³»: å±å¹å·¦ä¸è§ä¸ºåç¹ (0, 0)ï¼åå³ä¸º X å¢å ï¼åä¸ä¸º Y å¢å
- æé: Windows ä¸å¯è½éè¦ä»¥ç®¡çåæéè¿è¡æäºæä½
- å辨ç: 夿¾ç¤ºå¨ç¯å¢ä¸ï¼åæ å¯è½è·¨è¶å¤ä¸ªå±å¹
- å¾åè¯å«: åå±å¹å辨çåç¼©æ¾æ¯ä¾å½±åï¼å»ºè®®ä½¿ç¨ confidence åæ°æé«é²æ£æ§
å¿«éåè表
| ç¨æ·è¾å ¥ | AI è¡å¨ |
|---|---|
| “xxx” | ç´æ¥æ§è¡ xxx |