我的鼠标侧面有额外的前进和后退按钮,这是我使用的 AHK 脚本,它的主要用途是:
- 如果在按住 XButton2(前进按钮)和右键(右键单击)的同时向上滚动鼠标中键,则会发送Alt+ 6。
- 如果在按住鼠标 XButton2 的同时向上滚动鼠标中键,系统音量将增加 2%
问题是它同时还会触发鼠标 XButton2(前进)的默认操作,所以我想阻止它在我按住上述键时发送“前进”。
~XButton2 & WheelUp::
GetKeyState, RButtonState, RButton, ;Gets the mouses Rbutton state
If RButtonState = D ;Checks if Rbutton is pressed down
if (x_1 > 1919) ;if mouse cursor's X(Horizontal) position is greater than 1919px then:
Send !6 ;Sends ALT+6
else Send !4 ;Sends ALT+4
SetNumlockState, On
If RButtonState = U ;Checks if Rbutton is NOT pressed down
SoundSet, + 2 ;if Rbutton is not pressed down scrolling up while holding XButton2 increases volume
return
答案1
这波浪符号前缀 (~)防止 AHK 阻止 XButton2 按键按下/弹起事件。它允许按键事件通过。
如果删除 ~,XButton2失去原有的功能为了避免这种情况,请让密钥自行发送:
XButton2 & WheelUp::
; do something
return
XButton2::Send {XButton2}