← 返回 Skills 市场
easonc13

Mac Control

作者 Eason Chen · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
1156
总下载
0
收藏
11
当前安装
1
版本数
在 OpenClaw 中安装
/install mac-control
功能描述
Control Mac via mouse/keyboard automation using cliclick and AppleScript. Use for clicking UI elements, taking screenshots, getting window bounds, handling c...
使用说明 (SKILL.md)

Mac Control

Automate Mac UI interactions using cliclick (mouse/keyboard) and system tools.

Tools

  • cliclick: /opt/homebrew/bin/cliclick - mouse/keyboard control
  • screencapture: Built-in screenshot tool
  • magick: ImageMagick for image analysis
  • osascript: AppleScript for window info

Coordinate System (Eason's Mac Mini)

Current setup: 1920x1080 display, 1:1 scaling (no conversion needed!)

  • Screenshot coords = cliclick coords
  • If screenshot shows element at (800, 500), click at (800, 500)

For Retina Displays (2x)

If screenshot is 2x the logical resolution:

# Convert: cliclick_coords = screenshot_coords / 2
cliclick c:$((screenshot_x / 2)),$((screenshot_y / 2))

Calibration Script

Run to verify your scale factor:

/Users/eason/clawd/scripts/calibrate-cursor.sh

cliclick Commands

# Click at coordinates
/opt/homebrew/bin/cliclick c:500,300

# Move mouse (no click) - Note: may not visually update cursor
/opt/homebrew/bin/cliclick m:500,300

# Double-click
/opt/homebrew/bin/cliclick dc:500,300

# Right-click
/opt/homebrew/bin/cliclick rc:500,300

# Click and drag
/opt/homebrew/bin/cliclick dd:100,100 du:200,200

# Type text
/opt/homebrew/bin/cliclick t:"hello world"

# Press key (Return, Escape, Tab, etc.)
/opt/homebrew/bin/cliclick kp:return
/opt/homebrew/bin/cliclick kp:escape

# Key with modifier (cmd+w to close window)
/opt/homebrew/bin/cliclick kd:cmd t:w ku:cmd

# Get current mouse position
/opt/homebrew/bin/cliclick p

# Wait before action (ms)
/opt/homebrew/bin/cliclick -w 100 c:500,300

Screenshots

# Full screen (silent)
/usr/sbin/screencapture -x /tmp/screenshot.png

# With cursor (may not work for custom cursor colors)
/usr/sbin/screencapture -C -x /tmp/screenshot.png

# Interactive region selection
screencapture -i region.png

# Delayed capture
screencapture -T 3 -x delayed.png  # 3 second delay

Workflow: Screenshot → Analyze → Click

Best practice for reliable clicking:

  1. Take screenshot

    /usr/sbin/screencapture -x /tmp/screen.png
    
  2. View screenshot (Read tool) to find target coordinates

  3. Click at those coordinates (1:1 on 1920x1080)

    /opt/homebrew/bin/cliclick c:X,Y
    
  4. Verify by taking another screenshot

Example: Click a button

# 1. Screenshot
/usr/sbin/screencapture -x /tmp/before.png

# 2. View image, find button at (850, 450)
# (Use Read tool on /tmp/before.png)

# 3. Click
/opt/homebrew/bin/cliclick c:850,450

# 4. Verify
/usr/sbin/screencapture -x /tmp/after.png

Window Bounds

# Get Chrome window bounds
osascript -e 'tell application "Google Chrome" to get bounds of front window'
# Returns: 0, 38, 1920, 1080  (left, top, right, bottom)

Common Patterns

Chrome Extension Icon (Browser Relay)

Use AppleScript to find exact button position:

# Find Clawdbot extension button position
osascript -e '
tell application "System Events"
    tell process "Google Chrome"
        set toolbarGroup to group 2 of group 3 of toolbar 1 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1
        set allButtons to every pop up button of toolbarGroup
        repeat with btn in allButtons
            if description of btn contains "Clawdbot" then
                return position of btn & size of btn
            end if
        end repeat
    end tell
end tell
'
# Output: 1755, 71, 34, 34 (x, y, width, height)

# Click center of button
# center_x = x + width/2 = 1755 + 17 = 1772
# center_y = y + height/2 = 71 + 17 = 88
/opt/homebrew/bin/cliclick c:1772,88

Clicking by Color Detection

If you need to find a specific colored element:

# Find red (#FF0000) pixels in screenshot
magick /tmp/screen.png txt:- | grep "#FF0000" | head -5

# Calculate center of colored region
magick /tmp/screen.png txt:- | grep "#FF0000" | awk -F'[,:]' '
  BEGIN{sx=0;sy=0;c=0}
  {sx+=$1;sy+=$2;c++}
  END{printf "Center: (%d, %d)\
", sx/c, sy/c}'

Dialog Button Click

  1. Screenshot the dialog
  2. Find button coordinates visually
  3. Click (no scaling on 1920x1080)
# Example: Click "OK" button at (960, 540)
/opt/homebrew/bin/cliclick c:960,540

Type in Text Field

# Click to focus, then type
/opt/homebrew/bin/cliclick c:500,300
sleep 0.2
/opt/homebrew/bin/cliclick t:"Hello world"
/opt/homebrew/bin/cliclick kp:return

Helper Scripts

Located in /Users/eason/clawd/scripts/:

  • calibrate-cursor.sh - Calibrate coordinate scaling
  • click-at-visual.sh - Click at screenshot coordinates
  • get-cursor-pos.sh - Get current cursor position
  • attach-browser-relay.sh - Auto-click Browser Relay extension

Keyboard Navigation (When Clicks Fail)

Google OAuth and protected pages block synthetic mouse clicks! Use keyboard navigation:

# Tab to navigate between elements
osascript -e 'tell application "System Events" to keystroke tab'

# Shift+Tab to go backwards
osascript -e 'tell application "System Events" to key code 48 using shift down'

# Enter to activate focused element
osascript -e 'tell application "System Events" to keystroke return'

# Full workflow: Tab 3 times then Enter
osascript -e '
tell application "System Events"
    keystroke tab
    delay 0.15
    keystroke tab
    delay 0.15
    keystroke tab
    delay 0.15
    keystroke return
end tell
'

When to use keyboard instead of mouse:

  • Google OAuth / login pages (anti-automation protection)
  • Popup dialogs with focus trapping
  • When mouse clicks consistently fail after verification

Chrome Browser Relay & Multiple Windows

Problem: Browser Relay may list tabs from multiple Chrome windows, causing snapshot to fail on the desired tab.

Solution:

  1. Close extra Chrome windows before automation
  2. Or ensure only the target window has relay attached

Check tabs visible to relay:

# In agent code
browser action=tabs profile=chrome

If target tab missing from list → wrong window attached.

Verify single window:

osascript -e 'tell application "Google Chrome" to return count of windows'

Verify-Before-Click Workflow

Critical: Always verify coordinates BEFORE clicking important buttons.

# 1. Take screenshot
osascript -e 'do shell script "/usr/sbin/screencapture -x /tmp/before.png"'

# 2. View screenshot (Read tool), note target position

# 3. Move mouse to verify position (optional)
python3 -c "import pyautogui; pyautogui.moveTo(X, Y)"
osascript -e 'do shell script "/usr/sbin/screencapture -C -x /tmp/verify.png"'

# 4. Check cursor is on target, THEN click
/opt/homebrew/bin/cliclick c:X,Y

# 5. Take screenshot to confirm action worked
osascript -e 'do shell script "/usr/sbin/screencapture -x /tmp/after.png"'

Troubleshooting

Click lands wrong: Verify scale factor with calibration script

cliclick m: doesn't move cursor visually: Use c: (click) instead, or check with cliclick p to confirm position changed

Permission denied: System Settings → Privacy & Security → Accessibility → Add /opt/homebrew/bin/node

Window not found: Check exact app name:

osascript -e 'tell application "System Events" to get name of every process whose background only is false'

Clicks ignored on OAuth/protected pages: These pages block synthetic events. Use keyboard navigation (Tab + Enter) instead.

pyautogui vs cliclick coordinates differ: Stick with cliclick for consistency. pyautogui may have different coordinate mapping.

Quartz CGEvent clicks don't work: Some pages (Google OAuth) block low-level mouse events too. Keyboard is the only reliable method.

安全使用建议
This skill appears to be a straightforward Mac UI automation toolkit, but take a few precautions before using it or letting an agent run it: - Verify required binaries are present and trustworthy: cliclick (at /opt/homebrew/bin/cliclick), ImageMagick (magick), sips, osascript, screencapture. The metadata does not declare these dependencies — install/validate them yourself. - The scripts assume specific paths (e.g., /Users/eason/clawd/ and /opt/homebrew/bin). Adjust paths to match your machine and inspect scripts before running. - Review the bundled shell scripts line-by-line (they are plain text) and test them in a safe environment. They move the mouse, send keystrokes, and capture screenshots — these actions can interact with sensitive UIs (passwords, 2FA popups, private documents). - Be cautious about giving an autonomous agent permission to execute these scripts: although the scripts do not perform network I/O, screenshots and keystrokes are sensitive surface area that could be exfiltrated if the agent is also allowed to send data externally. If you want to proceed: correct the binary paths, run the scripts manually once to confirm behavior, and restrict any agent-level network or file-transmission permissions until you trust the skill.
功能分析
Type: OpenClaw Skill Name: mac-control Version: 1.0.0 The skill bundle provides Mac UI automation capabilities, which are inherently high-privilege. It contains multiple shell and AppleScript injection vulnerabilities in its helper scripts (`scripts/find-element.sh`, `scripts/crop-image.sh`, `scripts/get-window-bounds.sh`). Arguments passed to `cliclick`, `sips`, and `osascript` are not properly sanitized or quoted, allowing for arbitrary command execution if an attacker or a prompt-injected agent can control the input to these scripts. There is no evidence of intentional malicious behavior like data exfiltration or persistence within the provided code, but these critical vulnerabilities pose a significant risk of exploitation.
能力评估
Purpose & Capability
The skill claims to automate Mac UI which is consistent with the provided scripts. However the registry metadata lists no required binaries or config, while the SKILL.md and scripts rely on specific tools (/opt/homebrew/bin/cliclick, magick/ImageMagick, sips, osascript, screencapture, system_profiler) and write a calibration file to ~/.clawdbot. The SKILL.md also references absolute user paths (/Users/eason/clawd/...) and helper scripts (attach-browser-relay.sh) that are not present in the package. These mismatches are unexpected and should be resolved before trusting the skill.
Instruction Scope
Instructions and scripts explicitly move the mouse, send keystrokes, take screenshots, inspect images, and query window bounds via AppleScript — all coherent with UI automation. They create and read files in /tmp and the user's home (~/.clawdbot) and assume the agent or user will open/read screenshot files to locate targets. This is in-scope but is privacy-sensitive (screenshots may contain sensitive data). There are no network calls or credential exfiltration in the scripts, but an agent with the ability to read and transmit files could leak screenshots, so run with that risk in mind.
Install Mechanism
No install spec (instruction-only with bundled scripts) — lowest install risk (no external downloads). The package contains shell scripts that will be available to run, but nothing in the skill performs network downloads or executes code from external URLs.
Credentials
The skill does not request any environment variables or credentials, which is appropriate. It does save calibration data under ~/.clawdbot and expects system binaries to exist; double-check those binaries/paths before use.
Persistence & Privilege
always is false and the skill does not request system-wide configuration changes. It writes a local calibration file (~/.clawdbot/mac-control-calibration.json) which is normal for a tool of this type. It does not modify other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install mac-control
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /mac-control 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial publish
元数据
Slug mac-control
版本 1.0.0
许可证
累计安装 12
当前安装数 11
历史版本数 1
常见问题

Mac Control 是什么?

Control Mac via mouse/keyboard automation using cliclick and AppleScript. Use for clicking UI elements, taking screenshots, getting window bounds, handling c... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1156 次。

如何安装 Mac Control?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install mac-control」即可一键安装,无需额外配置。

Mac Control 是免费的吗?

是的,Mac Control 完全免费(开源免费),可自由下载、安装和使用。

Mac Control 支持哪些平台?

Mac Control 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Mac Control?

由 Eason Chen(@easonc13)开发并维护,当前版本 v1.0.0。

💬 留言讨论