'How to create context-sensitive hotkeys when no window is active?

I want to create some hotkeys when no window is active:

enter image description here

But there's no statement like #IfNoWinActive, how to achieve this?



Solution 1:[1]

~Esc::
  WinGet A, PID, A

  if !A {
    MsgBox ; ? put logic here
  }
  return

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wenfang Du