autohotkey - 在 Microsoft Edge 处于活动状态时执行操作的自动热键脚本
问题描述
我正在尝试编写脚本以便在 Microsoft Edge 窗口处于活动状态时执行操作。我尝试了这些脚本:
#IfWinActive Microsoft edge
~$l::
KeyWait,l,T0.25
if (ErrorLevel)
{
send,^l
sleep,100
send,{Delete}
}
return
但它不识别窗户。#IfWinActive, ahk_class Microsoft Edge
我也尝试过不同的名字#IfWinActive Microsoft Edge.exe
。但他们都没有工作。
解决方案
在新的 Edge 选项卡上使用 Window Spy 向我展示了这一点:
在您将用于#IfWinActive 语句(、、或)的三个主要选项中WinTitle
,ahk_class
这ahk_exe
可能ahk_exe
是创建始终在 MS Edge 中运行的脚本的最佳选择,并且仅基于 Windows Spy显示。
基于此,我创建了这个通用脚本来检查是否在 Edge 中触发了热键
#IfWinActive, ahk_exe msedge.exe
^q::MsgBox Hotkey Triggered in Edge (msedge.exe)
#If
^q::MsgBox Hotkey Triggered in a different program
将您的原始脚本纳入其中:
#IfWinActive, ahk_exe msedge.exe
~$l::
KeyWait,l,T0.25
if (ErrorLevel)
{
send,^l
sleep,100
send,{Delete}
}
return
有关 #IfWinActive 的更多信息,请参阅文档。
也相关:在 AHK 论坛上发布关于如何使用带有程序名称、ahk_exe 和 ahk_class 的#IfWinActive 的帖子。
推荐阅读
- python - Python LXML 安装问题
- javascript - 使用请求模块处理错误 - 未定义的对象
- css - 单击时删除输入突出显示的框
- c# - 创建身份角色列表
- c# - IL代码调用不带参数的方法
- ruby-on-rails - 为什么在运行 `bundle install` 时会出现 SystemStackError?
- keras - 如何在 keras 中使用 dropout
- javascript - 在遍历每个 URL 的 for 循环下处理 getJson 下设置的标志值
- javascript - 如何在 Spring WebMVC 框架的 JSP 文件中包含外部 JS 文件?
- google-cloud-platform - 查看stackdriver中的所有日志