如何用单个鼠标控制两个光标?同步移动带偏移且同步左键点击是否可行?
Absolutely, this is totally doable! I’ve helped folks set up similar dual-cursor workflows before—here are two reliable methods to make your request a reality, depending on how tech-savvy you feel.
1. AutoHotkey(适合普通用户,Windows平台)
AutoHotkey is a free, powerful automation tool for Windows that’s perfect for customizing mouse behavior. It’ll let you sync two cursors with offset and mirror left-clicks in minutes.
步骤:
- Download and install AutoHotkey (no extra hoops, just grab it from their official site)
- Create a new text file, rename it to
DualCursor.ahk, and paste this code inside:
; 自定义偏移量(X/Y轴像素,可根据需求修改) offsetX := 20 offsetY := 10 ; 同步光标移动 ~MouseMove:: ; 获取主光标当前位置 MouseGetPos, mainX, mainY ; 计算副光标位置并移动 secondaryX := mainX + offsetX secondaryY := mainY + offsetY DllCall("SetCursorPos", "int", secondaryX, "int", secondaryY) return ; 同步左键点击 ~LButton:: ; 重新计算副光标位置(确保和主光标偏移一致) MouseGetPos, mainX, mainY secondaryX := mainX + offsetX secondaryY := mainY + offsetY ; 在副光标位置触发点击 DllCall("SetCursorPos", "int", secondaryX, "int", secondaryY) Click ; 切回主光标位置 DllCall("SetCursorPos", "int", mainX, "int", mainY) return
- Double-click the
.ahkfile to run it. You’ll see a tiny AutoHotkey icon in your system tray—leave it running, and your dual cursors will work as expected.
The ~ symbol in the code keeps your original mouse behavior intact (so your main cursor still works normally), while adding the secondary cursor sync. Tweak offsetX and offsetY to adjust how far the second cursor sits from the main one.
2. Python + PyAutoGUI(适合跨平台/有编程基础的用户)
If you’re on macOS/Linux or want more flexibility, you can use Python with the pyautogui library to build your own dual-cursor tool.
步骤:
- Install the library first with this command in your terminal:
pip install pyautogui
- Create a Python script (e.g.,
dual_cursor.py) with this code:
import pyautogui import time # 设置偏移量(可自定义) offset_x = 20 offset_y = 10 # 记录上一次主光标位置,避免重复操作 last_x, last_y = pyautogui.position() try: while True: current_x, current_y = pyautogui.position() # 当主光标移动时,更新副光标位置 if current_x != last_x or current_y != last_y: secondary_x = current_x + offset_x secondary_y = current_y + offset_y pyautogui.moveTo(secondary_x, secondary_y, duration=0) last_x, last_y = current_x, current_y # 检测左键点击并同步到副光标位置 if pyautogui.mouseDown(button='left'): pyautogui.click(secondary_x, secondary_y) # 等待左键释放,防止重复触发 while pyautogui.mouseDown(button='left'): time.sleep(0.01) time.sleep(0.01) except KeyboardInterrupt: print("Script stopped successfully.")
- Run the script with
python dual_cursor.py. PressCtrl+Cin the terminal to stop it.
Note for macOS users: You’ll need to go to System Settings > Privacy & Security > Accessibility and grant permission to your terminal/IDE to control your computer.
- The "second cursor" is a simulated one—your system only has one native cursor, but the script moves it back and forth so fast it looks like two. It’ll work for most use cases, though.
- If you want to add more features (like right-click sync or dynamic offset), you can tweak the code snippets above easily.
内容的提问来源于stack exchange,提问作者FudgeMuffins




