Jump to content
The simFlight Network Forums

Recommended Posts

Posted

This is my first post on this forum, so excuse me if I've got anything wrong.

The question is:

Is it possible, from my own code (c#) to send a keypress (m) to FSUIPC which another program, Airport Design Editor will trap as if it came from FSX.  All without losing focus from my program?

Not realizing that ADE uses FSUIPC instead of simconnect, I coded in simconnect.  ADE must somehow receive key presses 'm', 'o' and '.' from FSX, but FSX must have focus when those letters are pressed. 

Airport Design Editor has a feature which allows one to press 'm' whilst in FSX, triggering a marker to be placed at the exact location of the aircraft on ADE.  

The purpose of my program is to:

  • take a list of coordinates from Google Earth, via KML, and send them to FSX in order to position the aircraft position by position. 
  • send key 'm' to FSX so that ADE thinks I have pressed it whilst FSX has focus, when in fact my program still has focus.

If, for instance, I have 40 sets of coordinates, I can single step through them on my program, and markers will appear in ADE, so I can accurately draw to those markers.

 

I hope that makes sense.

 

Regards

Martin

 

 

Posted
Quote

Is it possible, from my own code (c#) to send a keypress (m) to FSUIPC which another program, Airport Design Editor will trap as if it came from FSX.  All without losing focus from my program?

Not without losing focus, no. The DLL has a method FSUIPCConnection.SendKeyToFS(). There are some overloads that take a reference to a form in your application to return the focus to.

e.g. The following line will:

1. Send a request to FSUIPC to fire an 'm' key press.

2. FSUIPC will make FSX the active window then send the 'm' key press

3. The DLL will then return focus to your form

FSUIPCConnection.SendKeyToFS(Keys.M, this);

The round trip for this is about 300ms, so you might see a flash as the FSX screen comes to the foreground. I suggest trying it and seeing if it's acceptable.

If it must be done by a key press then this is the best that can be done. The way Windows works, only the foreground (focused) window can read the keyboard buffer. It's impossible to send a key press to a specific window that isn't in focus. Windows only has a single, global, keyboard buffer and only the focused window can read it.

The alternative would be if ADE can use another method to receive instructions. e.g. if it responds to custom FSX controls (also known as 'events'), or values written to FSUIPC offsets. These can be used while the FSX window is in the background. But, this would require that the authors of ADE have built in such a feature and are listening for these signals. You would need to ask the authors or see if there is anything in the documentation.

Paul

Posted (edited)

Thanks so much Paul, the flash would be perfectly acceptable for what I am doing.  I will see if I can make that work.

Martin

P.S. It isn't happy with Keys.M It seems to be expecting an FsControl type.  This seems such a quick and easy solution too.

 

Edited by connomar
Late information
Posted

Thanks so much Paul, the flash would be perfectly acceptable for what I am doing.  Yup, that works, thanks for your help.

Martin

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.