With
Code: Select all
insert:: ;Object Grabber extending beginning of clip
if WinActive("ahk_class DigiAppWndClass")
Send !{NumpadAdd}
return
Pressing Insert will send
!{NumpadAdd} unless:
- The hotkey isn't detected or can't execute.
- The active window's class is not DigiAppWndClass.
Rather than going through all of the conditions that might prevent the hotkey from executing to determine whether the keys
will be sent, it is much easier to simply test whether they
are sent.
Code: Select all
insert:: ;Object Grabber extending beginning of clip
if WinActive("ahk_class DigiAppWndClass")
{
Send !{NumpadAdd}
MsgBox !{NumpadAdd} was sent.
}
return
Basically, if Send was called,
!{NumpadAdd} was sent. So another way is to check
ListLines.
Yet another way is to check
KeyHistory, which shows both sent keys and pressed keys. It would also show you whether the insert key was recognized as a hotkey.
That it was
sent doesn't mean it was received. To know whether it was received even when there are no observable effects, you would have to be at the receiving end.
The most common issue that prevents keys from being received is that the target window is running as administrator, and the script is neither running as administrator nor with
UI Access. However, in that case your script would not be sending the keys, because it would not detect the hotkey in the first place.
This pattern:
Code: Select all
x::
if WinActive("y")
action
return
performs the action if y is active, but otherwise prevents x from doing anything. Usually it is preferable to make the hotkey specific to one application, allowing it to perform other functions in other applications. For that you should use
#IfWinActive or
#If:
Code: Select all
#If WinActive("ahk_class DigiAppWndClass")
; #IfWinActive ahk_class DigiAppWndClass ; same effect
insert::Send !{NumpadAdd} ; return can be omitted now
delete:: ; or it can be written like before:
Send !{NumpadSub}
return
#If
; subsequent hotkeys are global