Install
openclaw skills install pyautogui-skillDesktop automation via PyAutoGUI. Use when: user needs to automate mouse/keyboard actions, GUI testing, click/type sequences, screen-based workflows, or repetitive desktop tasks. NOT for: web automation (use Playwright/Selenium), mobile automation, or image recognition at scale.
openclaw skills install pyautogui-skillDesktop automation using PyAutoGUI for mouse, keyboard, and screen control.
✅ USE this skill when:
❌ DON'T use this skill when:
PyAutoGUI includes fail-safes. NEVER disable them:
# Fail-safe: Move mouse to (0,0) to abort
pyautogui.FAILSAFE = True # Keep this!
# Add pauses for safety
pyautogui.PAUSE = 0.5 # Seconds between actions
import pyautogui
# Basic movement
pyautogui.moveTo(100, 100, duration=0.5)
pyautogui.click()
# Typing
pyautogui.write('Hello world!', interval=0.1)
# Keyboard shortcuts
pyautogui.hotkey('ctrl', 'c') # Copy
pyautogui.hotkey('ctrl', 'v') # Paste
import pyautogui
# Get screen size
width, height = pyautogui.size()
# Current position
x, y = pyautogui.position()
# Move mouse (duration in seconds)
pyautogui.moveTo(100, 100, duration=0.5)
pyautogui.moveRel(0, 50, duration=0.3) # Relative move
# Clicks
pyautogui.click() # Left click at current position
pyautogui.click(x=100, y=100)
pyautogui.rightClick()
pyautogui.doubleClick()
pyautogui.dragTo(200, 200, duration=0.5)
# Button control
pyautogui.mouseDown()
pyautogui.mouseUp()
import pyautogui
# Type text
pyautogui.write('Hello!', interval=0.1) # interval between chars
# Special keys
pyautogui.press('enter')
pyautogui.press(['up', 'up', 'down', 'down'])
# Key hold
pyautogui.keyDown('shift')
pyautogui.write('CAPS')
pyautogui.keyUp('shift')
# Hotkeys (shortcuts)
pyautogui.hotkey('ctrl', 's') # Save
pyautogui.hotkey('ctrl', 'shift', 'n') # New folder (Windows)
pyautogui.hotkey('command', 'space') # Spotlight (Mac)
# Modifiers
'ctrl', 'shift', 'alt', 'command' (Mac), 'win' (Windows)
# Navigation
'enter', 'tab', 'space', 'escape', 'backspace', 'delete'
'up', 'down', 'left', 'right'
'home', 'end', 'pageup', 'pagedown'
# Function keys
'f1' through 'f12'
# Other
'capslock', 'numlock', 'scrolllock'
'printscreen', 'pause'
import pyautogui
# Full screenshot
screenshot = pyautogui.screenshot()
screenshot.save('screen.png')
# Region screenshot
screenshot = pyautogui.screenshot(region=(0, 0, 300, 400))
# To file directly
pyautogui.screenshot('saved.png')
import pyautogui
# Find image on screen
location = pyautogui.locateOnScreen('button.png', confidence=0.8)
if location:
x, y = pyautogui.center(location)
pyautogui.click(x, y)
# Find all occurrences
locations = pyautogui.locateAllOnScreen('icon.png', confidence=0.8)
# Get center point
center = pyautogui.center(location) # Returns (x, y)
Note: confidence requires Pillow. Range 0-1, higher = more strict matching.
import pyautogui
import time
pyautogui.PAUSE = 0.5
# Click first field
pyautogui.click(x=100, y=200)
pyautogui.write('John Doe')
# Tab to next field
pyautogui.press('tab')
pyautogui.write('john@example.com')
# Submit
pyautogui.press('enter')
import pyautogui
# Minimize (Windows)
pyautogui.hotkey('win', 'down')
# Maximize
pyautogui.hotkey('win', 'up')
# Switch apps (Alt+Tab)
pyautogui.hotkey('alt', 'tab')
# Close window
pyautogui.hotkey('alt', 'f4') # Windows
pyautogui.hotkey('command', 'w') # Mac
import pyautogui
# Locate and click a button
button = pyautogui.locateOnScreen('submit_btn.png', confidence=0.9)
if button:
x, y = pyautogui.center(button)
pyautogui.click(x, y)
else:
print("Button not found!")
import pyautogui
# Pause between ALL actions (seconds)
pyautogui.PAUSE = 0.5
# Fail-safe (move to corner to stop)
pyautogui.FAILSAFE = True
# Timeout for locateOnScreen (seconds)
pyautogui.locateOnScreen('img.png', timeout=10)
import platform
system = platform.system()
if system == "Darwin":
# macOS shortcuts
cmd = 'command'
elif system == "Windows":
cmd = 'win'
else:
cmd = 'ctrl'
See scripts/ for reusable automation scripts:
scripts/click_image.py - Locate and click an imagescripts/type_sequence.py - Type a text sequencescripts/take_screenshot.py - Capture screen regionPermissions (macOS):
Permissions (Windows):
Linux:
sudo apt-get install python3-dev python3-pip
sudo apt-get install scrot python3-tk python3-dev
pip3 install pyautogui
confidence (try 0.7-0.9)# Reduce pause (but keep safe!)
pyautogui.PAUSE = 0.1
# Remove duration for instant moves
pyautogui.moveTo(100, 100) # No duration = instant
# Increase pause
pyautogui.PAUSE = 1.0
# Add explicit waits
import time
time.sleep(2) # Wait for UI to load
pip install pyautogui pyscreeze pillow
macOS additional:
brew install python-tk
Linux additional:
sudo apt-get install python3-dev python3-pip scrot python3-tk