If you're only looking to prevent those four specific commands you mentioned from executing when the game window doesn't have focus, you can check the "Stop command if target window focus is lost" option for those commands, which will immediately stop the command (and prevent any actions in it from executing) if the target window is not the active window (and will not attempt to switch to the target window).
Otherwise, you could enable the "Enable Auto Profile Switching" option on the "General" tab of the VoiceAttack options window, and have VoiceAttack switch to another (blank, without commands that trigger off keyboard shortcuts) profile when the game does not have focus (Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer and check the "'Enable profile switching for the following windows'" subsection of the "Profile Options General Tab" subsection of the "Profile and Profile Options Screens" section for more information).
If you want to disable keyboard shortcuts without switching profiles, you'd need a command that runs a loop checking whether the target window still has focus, and disables keyboard shortcuts if not, then re-enables them when focus is regained.