AutoHotKey 问题

AutoHotKey 问题

我有一个包含两部分的自动热键脚本,似乎其中一部分导致另一部分停止工作。

一部分负责每当我编辑脚本时,它就重新加载它c-s

第二部分,每当我使用 ConEmu 时映射LCtrl到键。Apps

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
If WinActive("script.ahk") {
  $>^s::
    Send >^s
    Sleep, 100
    Reload
  Return
}

#IfWinActive, ahk_class VirtualConsoleClass
{
  LCtrl::AppsKey
}

如果我保持LCtrl->Apps重新映射,自动重新加载将停止工作。

为什么?

答案1

只是为了确保万无一失,您是否尝试过使用 #IfWinActive 作为 script.ahk 热键执行以下操作?

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 

#IfWinActive script.ahk
$>^s::
Send ^s
Sleep, 100
Reload
Return

#IfWinActive, ahk_class VirtualConsoleClass
LCtrl::AppsKey

答案2

主要原因似乎是 TitleMatchMode。

此外

if Winactive("script.ahk")

只会运行一次,这不是那种 if-case 如果你想有条件地启用热键,请将它们放在 #if- 语句之间

尝试这个:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode,Slow

#IfWinActive, edit.ahk
~$>^s::
    Sleep, 100
    Reload
Return

#IfWinActive, ahk_class VirtualConsoleClass
    LCtrl::AppsKey
#If

相关内容