mroschk Posted February 5 Report Posted February 5 Hello, does anyone know how i can perform a long press of a key in FSUIPC using C# ? Right now i perform a "normal" keypress using FSUIPCConnection.SendKeyToFS(Keys k, SendModifierKeys mod); But tihs simulates just a "Keypress" and not a longer press of a Key. Matthias
John Dowson Posted February 6 Report Posted February 6 You can send separate key down and key up events via offset 0x3200, Are you using @Paul Henty's .Net client dll? If so, better to post in the .Net client dll sub-forum - I can move this post... John
mroschk Posted February 6 Author Report Posted February 6 Hello, thhanks for the Answer, yes i use the client.dll for FSUIPC7. I am not sure if they is from @Paul Henty. Its called "FSUIPCClient.dll". Matthias
Paul Henty Posted February 6 Report Posted February 6 I'll can a new method for this. Probably SendKeyHoldToFS. You'll be able to specify how long to hold the key for. Would that be suitable or do you need separate key down/up calls and do the timing yourself? Paul
mroschk Posted February 6 Author Report Posted February 6 Hello, that would be nice. But i think there must be any method, or maybe a time in seconds in the method for the release of the Key. Otherwiese it keeps being pressed 🙂 If you create this Method, please dont forget the Modifier Keys like shift,alt, strg 😉 Matthias
Paul Henty Posted February 6 Report Posted February 6 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 1
mroschk Posted February 6 Author Report Posted February 6 Thanks ...let me check ... i will come back...
mroschk Posted February 6 Author Report Posted February 6 Hello again, that works very well Thank you very much !! Can be closed. Matthias 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now