I've tried this here using the Key_Press_and_Hold control. It may not do what you're expecting.
It doesn't repeat the key until you call the release command. So you don't get the action repeating.
You can try it for yourself and see if it does what you're expecting... Just paste this into your code and call.
sendKeyHoldToFS - holds the key for the specified HoldTime (in milliseconds) then releases it.
sendKeyDownToFS - presses the key down but does not release it.
snedKeyUpToFS - releases the key.
private void sendKeyHoldToFS(Keys Key, SendModifierKeys Modifiers, int HoldTime)
{
// First make sure FSX has the focus
SendControlToFS(FSUIPCControl.Key_focus_restore, 0);
// Wait for focus change
Thread.Sleep(150);
// Send the key down
SendControlToFS(FSUIPCControl.Key_Press_and_Hold, (int)Key + ((int)Modifiers * 256));
// Wait
Thread.Sleep(HoldTime);
// send the key up
SendControlToFS(FSUIPCControl.Key_Release, (int)Key + ((int)Modifiers * 256));
}
private void sendKeyDownToFS(Keys Key, SendModifierKeys Modifiers, int HoldTime)
{
// First make sure FSX has the focus
SendControlToFS(FSUIPCControl.Key_focus_restore, 0);
// Wait for focus change
Thread.Sleep(150);
// Send the key down
SendControlToFS(FSUIPCControl.Key_Press_and_Hold, (int)Key + ((int)Modifiers * 256));
}
private void sendKeyUpToFS(Keys Key, SendModifierKeys Modifiers, int HoldTime)
{
// First make sure FSX has the focus
SendControlToFS(FSUIPCControl.Key_focus_restore, 0);
// Wait for focus change
Thread.Sleep(150);
// Send the key down
SendControlToFS(FSUIPCControl.Key_Release, (int)Key + ((int)Modifiers * 256));
}
Paul