I do a lot of drafting work with AutoCAD and a couple years ago I did a little research on different approaches to using a second keyboard in conjunction with macros to simulate multiple keystrokes with a single key press.
The best program I came across for distinguishing 2 different keyboards was HID macros (which you mentioned). I found a few vague references in how AutoHotkey could work with multiple devices, but I never got far enough in figuring it out. I never tried to get HID macros to work with multiple windows, so I can’t comment on that. For assigning standard keyboard shortcuts, I found it easy with the “wizard” interface. More complicated stuff was possible with scripting languages. The program wasn't 100% bug free (on the rare occasion the actual keystroke would get passed instead of the macro), but overall I was very pleased.
As time wore on, I lusted for more shortcuts than the number pad could provide. Ultimately I dumped it for Logitech G13. I've definitely made use of the additional keys and would have a hard time going back. The G13 appears to have the ability to differentiate between multiple windows (again, not something that I’ve ever tried). Notable downside is the price. If you go that route, do a little research on the controller software. Logitech has both the new ( version 8 ) and legacy ( version 3 ) software available for download. Lots of people (including me) found the new software to be buggy and ended up going back to the legacy version.