马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
注:罗技鼠标,使用久了之后会出现连击现象,假如刚好过保了,可以思量使用软件方案解决连击现象:
以下是示例AutoHotKey脚本,实现了调用XButton1用于关闭窗口(以及Win+W,XButton2也导向关闭窗口,关闭窗口使用了函数Close),其中解决罗技鼠标侧键1(XButton1)所出现的连击现象.
- ; 可以使用命令#CommentFlag //将注释符; 换为双斜杠
- ;^ Ctrl
- ;! Alt
- ;+ Shift
- ;# Win
- /*
- * 修饰符
- 通配符: 即使附加的修饰键被按住也能激发热键. 这常与 重映射 按键或按钮组合使用.
- ~ 修饰符
- 激发热键时,不会屏蔽(被操作系统隐藏)热键中按键原有的功能。
- $ 修饰符
- 通常只在脚本使用 Send 命令发送包含了热键自身的按键时才需要使用此符号, 此时可以避免触发它自己.
- $ 前缀强制使用 键盘钩子 来实现此热键, 作为一个副作用这样避免了 Send 命令触发它自己.
- $ 前缀相当于在此热键定义之前的某个位置指定了 #UseHook。
- */
- $^w::Close()
- return
- #w::Close()
- return
- XButton1::Close()
- return
- XButton2::Close()
- return
- Close()
- {
- ; WinGetClass, class, A
- ; MsgBox, The active window's class is "%class%".
- ; WinGetTitle, Title, A
- ; MsgBox, The active window is "%Title%".
- ;微信
- IfWinActive, ahk_class WeChatMainWndForPC
- {
- WinMinimize
- return
- }
- ;企业微信
- IfWinActive, ahk_class WeWorkWindow
- {
- WinMinimize
- return
- }
- ;资源管理器
- IfWinActive, ahk_class CabinetWClass
- {
- WinClose
- return
- }
-
- ;.chm Help
- IfWinActive, ahk_class HH Parent
- {
- WinClose
- return
- }
- SetTitleMatchMode, RegEx
- ; Outlook 主窗口
- IfWinActive, .+Outlook$ ahk_class rctrl_renwnd32
- {
- WinMinimize
- return
- }
-
- SetTitleMatchMode, RegEx
- ; SetTitleMatchMode, slow
- ; Outlook 邮件窗口 .+邮件.*
- IfWinActive, .+(?!Outlook$).* ahk_class rctrl_renwnd32
- {
- WinClose
- return
- }
- ; SetTitleMatchMode, 1
- ; SetTitleMatchMode Fast
- ; 防止出现鼠标连击现象
- if (A_PriorHotkey == "XButton1" && A_ThisHotkey == "XButton1" && A_TimeSincePriorHotkey<200)
- {
- ; Send ^w ; 防止出现鼠标连击现象,这里要空操作!
- ; MsgBox, % "AAA" . A_ThisHotkey . "bbb" . A_TimeSinceThisHotkey
- }
- else
- {
- Send ^w
- }
- }
复制代码 --------分割符--------
代码使用XButton1来关闭窗口,关闭窗口使用Close()函数,也即XButton1::Close()。
关键代码:
if (A_PriorHotkey == "XButton1" && A_ThisHotkey == "XButton1" && A_TimeSincePriorHotkey< 200)
关键代码解释如下:A_PriorHotkey代表上一次的按键,A_ThisHotkey代表本次的按键,A_TimeSincePriorHotkey代表2次按键的隔断时间(毫秒),代码寄义:假如上一次按键和本次按键均为XButton1,且2次隔断小于200,则{}代表空操纵(分号注释代码),否则,将再次发送^w关闭窗口。留意,为了防止死循环调用,$^w::Close()的$代表仅键盘真正的按键^w也即Ctrl+W可以触发Close()函数。否则,本函数只发送^w也即Ctrl+W且不再循环触发Close函数。
实际应用情况中,根据鼠标连击的隔断快慢,可以将200设置为你想要的符合的值。
也可以将代码中,最后部分的 Send ^w 改为 Send XButton1,如许,也可以使XButton1避免重复发送(屏蔽了第2次的发送)。本次案例,精减后的代码【仅针对XButton1】:
- ; 本代码用于阻止XButton1(侧按键1)出现的连击现象
- ; $ 前缀强制使用 键盘钩子 来实现此热键, 作为一个副作用这样避免了 Send 命令触发它自己
- $XButton1::DoXButton1()
- return
- DoXButton1()
- {
- ; 防止出现鼠标连击现象
- if (A_PriorHotkey == "XButton1" && A_ThisHotkey == "XButton1" && A_TimeSincePriorHotkey<200)
- {
-
- }
- else
- {
- Send XButton1
- }
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |