You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
AutoClick/temp_mouse_control.py

49 lines
1.5 KiB

import subprocess
import time
import os
def test_mouse_movement_cliclick():
print("🐭 鼠标移动测试程序 (cliclick 版本)")
print("=" * 40)
# 检查 cliclick 是否安装
try:
result = subprocess.run(['which', 'cliclick'], capture_output=True, text=True)
if result.returncode != 0:
print("❌ cliclick 未安装")
print("请先安装: brew install cliclick")
return
except:
print("❌ 无法检查 cliclick 安装状态")
return
# 获取屏幕尺寸
try:
screen_width, screen_height = 2560, 1440 # 常见 Mac 分辨率,您可能需要调整
center_x = screen_width // 2
center_y = screen_height // 2
print(f"假设屏幕尺寸: {screen_width} x {screen_height}")
print(f"中心点坐标: ({center_x}, {center_y})")
print("3秒后移动鼠标到屏幕中心...")
for i in range(3, 0, -1):
print(f"{i}...")
time.sleep(1)
# 使用 cliclick 移动鼠标
command = f"cliclick m:{center_x},{center_y}"
print(f"执行命令: {command}")
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print("✅ cliclick 移动成功!")
else:
print(f"❌ cliclick 移动失败: {result.stderr}")
except Exception as e:
print(f"❌ 出错: {e}")
if __name__ == "__main__":
test_mouse_movement_cliclick()