you just need to create a group for each program and edit the group properties to tell it that it is only active when a particular program has focus.
In group properties, you just need to enter the name of the process in the "active only for process" text box. (The process name is usually the name of the program, but you can verify this in process manager when the program is running by hitting Ctrl-Shift-Esc and then clicking the processes tab).
If you different programs use similar hotkeys, you can create one group, and then clone it, and make the necessary adjustments for the next program.
Should be pretty easy.
I recommend that you use inputKeys for keyboard input, and if they don't work for some reason in a particular program, you can try using DxInput plugin.
It's also possible to create custom command to enable and disable different groups, but in this case I think it is simplest to use the group properties, since you will only ever want to use these commands when the program in question has focus.