Mouse & Keyboard Control
Use cliclick tool for mouse/keyboard automation on Mac.
Tools
exec
Use exec to run cliclick commands.
Available Commands
- -
c:X,Y - Click at coordinates X,Y - INLINECODE3 - Click at relative position
- INLINECODE4 - Wait 500ms
- INLINECODE5 - Type "hello"
- INLINECODE6 - Key down command
- INLINECODE7 - Key up command
- INLINECODE8 - Press return/enter
- INLINECODE9 - Press space
- INLINECODE10 - Press tab
- INLINECODE11 - Move mouse to X,Y
- INLINECODE12 - Double click
- INLINECODE13 - Right click at X,Y
Common Workflows
Click at position
CODEBLOCK0
Type text
CODEBLOCK1
Click and type
CODEBLOCK2
Keyboard shortcut
CODEBLOCK3
Move and click
CODEBLOCK4
Getting Coordinates
Use cliclick p to print current mouse position, or use macOS screenshot tool (Shift+Cmd+4) to get coordinates.
Notes
- - Coordinates are screen-based (0,0 is top-left)
- Use
osascript for more complex keyboard operations - Combine with
sleep for timing
鼠标与键盘控制
使用 cliclick 工具在 Mac 上实现鼠标/键盘自动化。
工具
exec
使用 exec 运行 cliclick 命令。
可用命令
- - c:X,Y - 在坐标 X,Y 处点击
- c:~100,~200 - 在相对位置点击
- w:500 - 等待 500 毫秒
- t:hello - 输入hello
- kd:cmd - 按下 Command 键
- ku:cmd - 松开 Command 键
- p:return - 按下回车键
- p:space - 按下空格键
- p:tab - 按下 Tab 键
- m:X,Y - 移动鼠标到 X,Y
- dp - 双击
- rc:X,Y - 在 X,Y 处右键点击
常见工作流程
在指定位置点击
bash
cliclick c:500,300
输入文本
bash
cliclick t:Hello World
点击并输入
bash
cliclick c:500,300 && cliclick t:username
键盘快捷键
bash
cliclick kd:cmd ku:cmd # 按下 Command 键
移动并点击
bash
cliclick m:100,100 && cliclick c:100,100
获取坐标
使用 cliclick p 打印当前鼠标位置,或使用 macOS 截图工具(Shift+Cmd+4)获取坐标。
注意事项
- - 坐标基于屏幕(0,0 为左上角)
- 对于更复杂的键盘操作,使用 osascript
- 结合 sleep 进行时间控制