运行 热键,如果没有 window 处于活动状态

Run hotkey if no window is active

我的问题是我想用 AHK 创建快捷方式。当我打开不同的 windows 时,快捷方式应该做不同的事情。

这是我当前的代码:

#SingleInstance, force
#IfWinActive, ahk_exe explorer.exe

CapsLock & P::
    Send, !FR
return

#IfWinActive 

CapsLock & P::
    Run, powershell, , , PID
    WinWait, ahk_pid %PID%
    WinActivate, ahk_pid %PID%
    Send, CD /{Enter}cls{Enter}
return

有效,除非没有 window 处于活动状态。

如何让它检查是否没有 window 处于活动状态(以桌面为主为例)?

当桌面聚焦时explorer.exe活动的window(它是windows 事物)。所以这是个问题。

如果其他快捷方式需要 运行 当文件资源管理器处于活动状态时,它可以与桌面以其标题为焦点时处于活动状态的资源管理器区分开来(当桌面获得焦点时,标题为空白).

#IfWinActive File Explorer ahk_exe explorer.exe