I am currently writing a program that takes a joystick input, and simulates key presses (hold) in the active window (a game). This should be used for a virtual H-Shifter, like the one in a car, to change gears.

My problem, is that I cannot find a command to hold down a key until I tell it to release.

I have tried

'SendKeys.Send("{1 down}")
'SendKeys.Send("{1 up}")

However, this does not seem to work (it comes up with an error "Specified repeat count is not valid.")

Can anyone help me with a command that will do this?

Thanks in advance!

P.S. This was originally in the games section but I was not sure that was right so I have put it here as well. Hope this does not cause and inconvenience