Autohotkey 热键使自动热键在重新加载之前处于非活动状态

Autohotkey 热键使自动热键在重新加载之前处于非活动状态,autohotkey,Autohotkey,对不起,我的英语不好 #IfWinActive, ahk_class PX_WINDOW_CLASS ~^s:: KeyWait, s, U WinWait, This is an unregistered copy ahk_class #32770,, 500 IfWinExist, This is an unregistered copy ahk_class #32770 WinKill, This is an unregistered copy ahk_class #32770

对不起,我的英语不好

#IfWinActive, ahk_class PX_WINDOW_CLASS

~^s::
KeyWait, s, U
WinWait, This is an unregistered copy ahk_class #32770,, 500
IfWinExist, This is an unregistered copy ahk_class #32770
    WinKill, This is an unregistered copy ahk_class #32770
Return

我的问题是,有时按下此热键(ctrl+s)会使所有自动热键脚本热键和自动热键的任务栏菜单快捷键处于非活动状态(未暂停或挂起,只是热键不起作用)。为什么呢?如何解决此问题?

您提供的信息很少。。。我可以想象,在PX_窗口_类中,您可能会点击Ctrls来保存文件。如果当时没有激活与winwait匹配的窗口,则不会发生任何事情,AutoHotKey将一直等待

建议:缩短WinWait中的超时时间,添加出口并删除多余的行

SetTitleMatchMode=2 ; Find the string "This is an unregistered copy" anywhere in your Title
#IfWinActive, ahk_class PX_WINDOW_CLASS
    ~^s::
    KeyWait, s, U ; Why do you have this in there? are you hanging on your s key for more than 2 seconds?
    WinWait, This is an unregistered copy,,2 ; Wait for two seconds (or a bit longer..)
    if ErrorLevel ; If timeout of WinWait
        Return
    WinKill ; uses ID found in WinWait
    Return
#IfWinActive
或者更短

SetTitleMatchMode=2
#IfWinActive, ahk_class PX_WINDOW_CLASS
~^s::
    WinWait, This is an unregistered copy,,2
    if not ErrorLevel
        WinKill ; uses ID found in WinWait
Return
#IfWinActive

您是否在最后“关闭”了IfWinActive?在Return下,添加一行
#IfWinActive
。看看这是否解决了您的问题。在我发布了脚本的一部分后,出现了#IfWinActive,ahk#U group ExplorerWindows。请提供一些建议解决方案的反馈,如果其中一个答案有帮助,请单击白色复选标记将其变为绿色,以“接受”该答案。非常感谢。好吧,我只是把500换成了1。我以为是几毫秒。嗯,我从你的代码注释中发现了这一点。我应该把这个标记为答案吗?@T-,很高兴看到你解决了这个问题。如果你能核对我的答案,我将不胜感激。