Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS命令行操作鼠标键盘 #75

Open
toplhy opened this issue Jan 8, 2025 · 0 comments
Open

MacOS命令行操作鼠标键盘 #75

toplhy opened this issue Jan 8, 2025 · 0 comments
Labels

Comments

@toplhy
Copy link
Owner

toplhy commented Jan 8, 2025

1. 安装cliclick工具

cliclick 是一个 macos 的命令行工具,用于模拟鼠标和键盘事件。

brew install cliclick

2. 编写AppleScript脚本

-- 使用System Events模拟鼠标点击
tell application "System Events"
    -- 设置鼠标位置,这里的x和y需要根据实际游戏窗口中的位置调整
    set mouseX to 500 -- 设置鼠标的x坐标
    set mouseY to 300 -- 设置鼠标的y坐标

    -- 移动鼠标到指定位置
    do shell script "/usr/local/bin/cliclick m:" & mouseX & "," & mouseY

    -- 模拟鼠标点击
    do shell script "/usr/local/bin/cliclick c:" & mouseX & "," & mouseY
end tell
@toplhy toplhy added the MacOS label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant