TL/DR: I have a decent method for making AHK work with multiple keyboards.
You can now use a 2nd (or 3rd, or 4th) keyboard to trigger AHK hotkeys and hotstrings, and block the key on the 2nd keyboard from doing anything
How it works:
You load my code from your script, pass it a function object and tell it which keyboard to watch (Using it's VID / PID). Whenever a key event from that keyboard happens, my code calls your function before sending the keystroke and after sending the keystroke.
Your function then sets a variable which is used for an
#ifblock, which turns on or the hotkeys for the 2nd keyboard.
Bear in mind that if you hold a key, it only wraps the EVENTS - ie you press the key, if fires
<set context true>, <send key down event>, <set context false>. You then release the key, and it fires
<set context true>, <send key up event>, <set context false>.
If you hold a key, when it repeats, the down events are wrapped just like a key press.
This should mean that it is possible to be holding the same key on two different keyboards, and they both function correctly and independently.
VID := 0x04F2, PID := 0x0112
Interception.SetContextCallback(VID, PID, Func("SetKb1Context"))
Sleep 0 ; needed to make hotstrings work, not sure why
isKeyboard1Active := state
; These hotkeys will only trigger for the 2nd keyboard
F1::msgbox 2nd keyboard
; These hotkeys will trigger for any keyboard
F2::msgbox Any keyboard
Also there is a "Subscription Mode" which completely circumvents AHK's hotkey system, and allows you to receive notification of key events via callback functions.
Using Subscription Mode plus SendKeyEvent, you can completely remap keys, per-device, in a way totally indistinguishable by Windows from the real thing