如何在另一个程序(例如 Microsoft Edge)打开时暂停 ahk 脚本?
How to suspend an ahk script when another programm (eg. Microsoft Edge) is open?
我是编码菜鸟,所以请多多包涵。所以我想要的是能够快速搜索 chrome 中的选定文本,除非 Microsoft Edge 浏览器打开,在这种情况下脚本应该被暂停。此外,如果脚本被挂起,^+e 应该像往常一样真正通过 Cntrl + 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) 指令很好。
有了它,您可以将所需的热键标记为不在某些特定的 window(s).
下
#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 := "Whosebug autohotkey questions"
Run, % "chrome.exe ""https://www.google.com/search?q=" TextToSearch """"
您可以从Clipboard
(docs)访问系统剪贴板。
我是编码菜鸟,所以请多多包涵。所以我想要的是能够快速搜索 chrome 中的选定文本,除非 Microsoft Edge 浏览器打开,在这种情况下脚本应该被暂停。此外,如果脚本被挂起,^+e 应该像往常一样真正通过 Cntrl + 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) 指令很好。
有了它,您可以将所需的热键标记为不在某些特定的 window(s).
#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 := "Whosebug autohotkey questions"
Run, % "chrome.exe ""https://www.google.com/search?q=" TextToSearch """"
您可以从Clipboard
(docs)访问系统剪贴板。