我是一个编码新手,所以请原谅我。所以我想要的是能够在chrome中快速搜索选定的文本,除非Microsoft Edge浏览器是打开的,在这种情况下,脚本应该被暂停。此外,如果脚本暂停^+e应该像往常一样通过ctrl + Shift +e。这是我得到的结果:
^+e::
Send, ^c
Sleep, 100
Run, www.google.com
Sleep, 100
Send, ^v
Send, {Enter}
Sleep, 300
Send, ^v
Send, {Enter}
Sleep, 300
Send, ^v
Send, {Enter}
Sleep, 300
Send, ^v
Send, {Enter}
Sleep, 300
Send, ^v
Send, {Enter}
Sleep, 300
Send, ^v
Send, {Enter}
return
IfWinActive, Microsoft Edge
{
Suspend, on
}
else
{
Suspend, off
}
return
我真的不确定IfwinActive线。谢谢你的帮助。
上下文敏感热键是为此制作的。
对于这种特殊情况,#IfWinNotActive
(docs)指令是很好的。
有了它,你可以标记所需的热键不在某些特定的窗口
#IfWinNotActive, ahk_exe msedge.exe ;start context sensitive hotkeys
^+e::
MsgBox, % "Do something"
;...
return
+F1::
MsgBox, % "Do something"
;...
return
#IfWinNotActive ;end context sensitive hotkeys
还有,我真的不明白你在做什么ctrl+v垃圾邮件,但是要搜索一些东西,也许可以考虑像这样运行:
TextToSearch := "stackoverflow autohotkey questions"
Run, % "chrome.exe ""https://www.google.com/search?q=" TextToSearch """"
您可以从Clipboard
(docs)访问系统剪贴板。