Seems like you're going to have a fight with windows over control of the keyboard input focus.
When you run your program - from a command line or through windows explorer, the keyboard focus moves to whatever window you used to run the program.
One the program starts, as a console program it will create it's own window and again take the keyboard input focus.
More than likely the program is sending the spacebar to itself.
Add code to your program to locate the top window of the application you want to control and set the focus to the other application - before sending a space bar.
To further reduce the intrusiveness of your program, rewrite it as WinMain() instead of main. Set the project as a Windowed subsystem application instead of a console application. A program that runs under WinMain and never creates a window can't take the input focus.
One minor suggestion - the scan code for the spacebar appears to 0x39. Probably not needed but doesn't hurt.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646304(v=vs.85).aspx[
^]