Autoit. It allows you to send key presses to a window. Just look for "Send" in the help file.
You should try Autohotkey, it's the latest version of autoit.
You can use it to send commands and change buttons.
See my script below for a game called "DeBlob"
Create trackball game.
***********************************************
run "C:\games\TheBlob\De Blob\Blob EN\De Blob.exe" EN
WinWait, De Blob
WinWaitClose, De Blob
ExitApp
Return
y::space
v::LButton
u::RButton
***********************************************
With this script the first part allows my ESC key to close the program.
(The program requires you to go to a menu and then click exit, which I did not want it to do).
The next section re-assign keystrokes.
To jump in the game you had to hit the space bar, I changed it to "y". That's the key I wanted on my control panel.
The next two buttons were re-assigned to simulate the left and right mouse clicks which are needed during the game.
Good luck.
BG66