(敲出一个完成基本功能的初步脚本和我想象的一样简单。只花了几分钟,而且工作得相当好。问题是有很多小问题和边缘情况,有些东西可能无法正常工作某些特定情况或是否存在其他特定期望。我仍在研究处理双击和拖动的脚本的增强版本,但是虽然有大量示例和尝试,但没有可靠、有效和简洁的示例在这个时候很好地处理这些,所以这是一项正在进行的工作。)
无论如何,下面的脚本是我拼凑起来的旧版本(并清理了一点供公众使用)。它执行所要求的操作(以及更多操作)。没有真正的手册;您只需运行脚本,它就会以镜像模式启动。在屏幕两侧的鼠标点击会在另一半(垂直)上重复。有几个热键可用于修改脚本行为:
这是脚本的示例输出:

Mirror.ahk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mirror.ahk mirrors mouse clicks on one half of the screen to the other half
; http://superuser.com/questions/393738/
;
; (cl) 2012- Synetech inc., Alec Soroudi
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Hotkeys:
; Alt+Shift+Q to toggle mirroring
; Ctrl+Shift+Q to toggle autofire
; Ctrl+Alt+Shift+Q to completely pause the script (mouse behaves normally)
; Ctrl+Alt+Shift+Win+Q to quit
;
; Defaults to single-click, mirrored
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#SingleInstance force
CoordMode, Mouse, Screen
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SendMode Play ;Try modes Event, Input, or Play
;Variables
SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index%
Half := (MonitorWorkAreaRight - MonitorWorkAreaLeft) >> 1
Mirror := 1
Autofire := 0
;Main function
Dupe(action, var) {
;Calculate other half
MouseGetPos, x,y
Global Half
if (x<Half) {
Left := (Half + x)
}
else {
Left := (x - Half)
}
Global Mirror
if (action=0) { ;Mouse
if (var=0) { ;Left-click
if Mirror
Click %Left% %y% Left
Click %x% %y% Left
}
else if (var=1) { ;Right-click
Click %Left% %y% Right
Click %x% %y% Right
}
else if (var=2) { ;Middle-click
Click %Left% %y% Middle
Click %x% %y% Middle
}
else if (var=3) { ;Button4-click
Click %Left% %y% X1
Click %x% %y% X1
}
else if (var=4) { ;Button5-click
Click %Left% %y% X2
Click %x% %y% X2
}
}
; else if (action=1) { ;Keyboard - do what???
; }
}
;Hotkeys
!+q:: ;Pause mirroring with Alt+Shift+Q
Mirror := !Mirror
; MsgBox Mirror: %Mirror%
return
^+q:: ;Toggle autofire with Ctrl+Shift+Q
Autofire := !Autofire
; MsgBox Autofire: %Autofire%
return
^!+q:: ;Pause script with Ctrl+Alt+Shift+Q
Suspend
; if (A_IsSuspended = 1)
; MsgBox Hotkeys suspended
; else
; MsgBox Hotkeys resumed
return
^!+#q:: ;Quit with Ctrl+Alt+Shift+Win+Q
; MsgBox Quitting
ExitApp
return
+#q:: ;Reload/restart script with Shift+Win+Q
; MsgBox Reloading
Reload
return
;Handlers
*$LButton::
Loop {
; if (Mirror)
Dupe(0, 0)
GetKeyState, State, LButton, P
if (!Autofire || State = "U")
Break
}
return
*$RButton::
Loop {
if (Mirror)
Dupe(0, 1)
GetKeyState, State, RButton, P
if (!Autofire || State = "U")
Break
}
return
*$MButton::
Loop {
if (Mirror)
Dupe(0, 2)
GetKeyState, State, MButton, P
if (!Autofire || State = "U")
Break
}
return
*$XButton1::
Loop {
if (Mirror)
Dupe(0, 3)
GetKeyState, State, XButton1, P
if (!Autofire || State = "U")
Break
}
return
*$XButton2::
Loop {
if (Mirror)
Dupe(0, 4)
GetKeyState, State, XButton2, P
if (!Autofire || State = "U")
Break
}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21868 次 |
| 最近记录: |