求Autohotkey v2实现Windows 11一键清除所有通知的快捷键方案
使用AutoHotkey v2设置快捷键清除Windows 11所有通知
以下是适配AutoHotkey v2的脚本,可自定义快捷键一键清除所有通知:
^+N:: ; 自定义快捷键:Ctrl+Shift+N,可修改为其他组合(如!N::代表Alt+N) { ; 打开通知中心 Send "#n" ; 等待通知中心加载完成,根据系统性能可调整毫秒数 Sleep 150 ; 等待通知中心窗口激活,超时2秒则退出 if !WinWaitActive("ahk_class Windows.UI.Core.CoreWindow",, 2) return ; 遍历通知中心控件,找到"清除所有通知"按钮并点击 ControlGetControls(&controls, "ahk_class Windows.UI.Core.CoreWindow") for control in controls { ControlGetText(&btnText, control, "ahk_class Windows.UI.Core.CoreWindow") ; 匹配按钮文本,英文系统请改为"Clear all notifications" if btnText = "清除所有通知" { ControlClick(control, "ahk_class Windows.UI.Core.CoreWindow") break } } ; 可选:再次发送Win+N关闭通知中心,若不需要可删除此行 Sleep 50 Send "#n" }
关键说明
- 快捷键修改:将
^+N::替换为你需要的组合,比如#F1::代表Win+F1,具体按键符号参考AutoHotkey v2规范。 - 语言适配:如果你的Windows是英文系统,将脚本中的
"清除所有通知"替换为"Clear all notifications"。 - 稳定性优化:如果通知中心加载较慢,可适当增大
Sleep的毫秒数;若控件查找失败,可使用AutoHotkey自带的WindowSpy.ahk工具查看通知中心的控件信息,调整匹配逻辑。 - 运行方式:将脚本保存为
.ahk后缀文件,确保已安装AutoHotkey v2,双击即可运行,快捷键即时生效。
内容的提问来源于stack exchange,提问作者user3848207
相关产品推荐
相关产品推荐

