我的这款鼠标侧面有额外的前进和后退按钮,这是我使用的 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
波形符前缀 (~)可防止 AHK 阻止 XButton2 按键按下/按下事件。它允许关键事件通过。
如果去掉~,XButton2就失去了原来的功能。为了避免这种情况,请让密钥自行发送: