Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Paul

 

I want to send Alt-Enter to FSX to toggle it in and out of full screen mode.

 

I can't find in the docs what the values are for the Alt key and the Enter key?

 

I will this structure below you gave to me in another thread to send these key strokes to FSX:

 

sendControl.Value = 65752; // parking brakes
FSUIPCConnection.Process("SendControl");

 

Thanks...

 

Posted

Looking through the control list document there is this control:

 

FULL_WINDOW_TOGGLE  65553

 

There seems to be some confusion about if this is P3D only but it's worth a try for FSX.

 

A dedicated control is much better than sending a key press. If that doesn't work or does something different than the full screen toggle then I'll have a look at the key press route.

 

Paul

Posted

Didn't do anything:

 

            ps.RefreshData();
            sendControl.Value = 65553; // full window toggle
            FSUIPCConnection.Process("SendControl");
            ps.WriteChanges();
            ps.RefreshData();
Posted

Okay - I'm looking into sending the key press but I can't get the key send control to work at the moment. I've asked Pete for some help so bear with me.

 

The full list of FSX/P3D controls is under your main FSX folder in the "Modules\FSUIPC Documents" folder. It's called "List of FSX and P3D controls,pdf".

 

In addition FSUIPC also has it's own set of controls listed in "FSUIPC4 for Advanced Users.pdf". (same folder).

 

Paul

Posted

Hi - The key press control only sends the keys to the active window so it's not as simple as it first looked. Switching focus to FSX is fairly complicated in C# so I'll have a look at building a keysend facility into the DLL this week.
 

Paul

Posted

OK, thanks Paul.

 

I'm certainly not a sharp C# developer by any means, but maybe the following code structure might help you in a small way. I use it to find running applications and I hardly use its full capabilities, but maybe there is something in that 'p' structure that will allow you to focus fsx. It's just code snippets from various things I've needed to do, nothing specific to what you need but maybe it will give you some idea's.

 

            System.Diagnostics.Process[] ieProcs = Process.GetProcessesByName("fsx");
            if (ieProcs.Length > 0)
            {
                foreach (System.Diagnostics.Process p in ieProcs)
                {
                    //this.Text = p.ProcessName;
                    //hWnd = p.MainWindowHandle;
                    // 0 hide
                    // 1 show
                    //this.ShowWindow(p.MainWindowHandle, 1);
                    hWnd = p.MainWindowHandle;
 
                    int style = GetWindowLong(hWnd, GWL_STYLE);
                    SetWindowLong(hWnd, GWL_STYLE, (style | WS_CAPTION));
                    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
 
                    //hWnd.WindowState = FormWindowState.Maximized;
                    //hWnd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                    // 0 hide
                    // 1 show normal
                    // 2 show minimized
                    // 3 show maximized
                    // 5 show
                    // 6 minimize
                    // 9 restore
                    //p.Kill();
                }
            }
 
Posted

Hi - The key press control only sends the keys to the active window so it's not as simple as it first looked. Switching focus to FSX is fairly complicated in C# so I'll have a look at building a keysend facility into the DLL this week.

 

Hi Paul,

 

There is a facility in FSUIPC to restore focus to FS, specifically for the keypress control. Please see my last answer to your question in the main forum, i.e. thread

 

http://forum.simflight.com/topic/78544-help-with-sending-key-presses-with-control-1070-via-0x3110/

 

Pete

Posted

Ralph,

 

Since Pete has pointed out an easy way to give focus to FSX, sending alt-enter now becomes fairly simple. The code is below. I will still add a feature to the DLL to make sending key strokes a bit easier and less verbose.

 

Declarations:

        private Offset<int> controlParameter = new Offset<int>("SendControl", 0x3114, true);
        private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true);
        private readonly int KEY_PRESS_RELEASE = 1070;
        private readonly int KEY_FOCUS_RESTORE = 1125;

Main Code:

            // Set FSX as active window
            sendControl.Value = KEY_FOCUS_RESTORE;
            FSUIPCConnection.Process("SendControl");
            // Send alt-enter
            sendControl.Value = KEY_PRESS_RELEASE;
            controlParameter.Value = (int)(Keys.Enter) + (256 * 16);
            FSUIPCConnection.Process("SendControl");

Paul

Posted

Hi Paul,

 

There is a facility in FSUIPC to restore focus to FS, specifically for the keypress control. Please see my last answer to your question in the main forum, i.e. thread

 

http://forum.simflight.com/topic/78544-help-with-sending-key-presses-with-control-1070-via-0x3110/

 

Pete

 

Hi Pete

 

Is there a way to detect which window mode FSX is in? Obviously I'm using Alt-Enter to toggle FSX in and out of full screen mode. But it would be handy to know first if FSX was already in window mode so then I don't have to send the Alt-Enter command.

 

Thanks...

Posted

Is there a way to detect which window mode FSX is in? Obviously I'm using Alt-Enter to toggle FSX in and out of full screen mode. But it would be handy to know first if FSX was already in window mode so then I don't have to send the Alt-Enter command.

 

FSUIPC doesn't know and there's no variable available in FS to tell it. I can only think you work it out using normal Windows tools, maybe to see if there are any sizing borders or title bar. I don't really know, it would need some research into Window properties.

 

Pete

Posted

OK. I can find FSX if it is running and I can fetch it's border state, etc. I'll create a function call I can use in my C# code.

 

Thanks...

Posted

Update: Here is the answer to my question on how to detect if FSX is in Full Screen mode or windowed mode.

 

It turns out it's not so easy to determine that. MS doesn't have a direct property for that so one has to use other mechanisms to achieve the same results.

 

Here is my solution in C# code that may help others who need to do the same thing.

 

I had to put this code in a timer, checking every 5 secs to see what mode fsx is in, then act accordingly for what I need to do.

 

I debugged this code using file writes since when fsx is in full window mode you can't have access to your app. I checked my debug writes to determine everything was working as expected to detect when fsx was in full screen mode. Then I sent the Alt-Enter command and fsx flipped back to windowed mode as I wanted.

 

I hope this helps someone else.

 

        private void timer_Tick(object sender, EventArgs e)
        {
            // first we use the GetProcessByName function to try and find fsx if it is running
            System.Diagnostics.Process[] ieProcs = Process.GetProcessesByName("fsx");
            if (ieProcs.Length > 0)
            {
                foreach (System.Diagnostics.Process p in ieProcs)
                {
                    // we have found fsx so it is running but we don't know yet what mode it is in
                    hWnd = p.MainWindowHandle;
                    // we will now attempt to get the fsx form title
                    const int count = 512;
                    var text = new StringBuilder(count);
                    if (GetWindowText(hWnd, text, count) > 0)
                    {
                        // we got it ! so this means fsx is in windowed mode
                        // I can successfully pop up my app when fsx is in windowed mode, so that's all I need here at this point
                    }
                    else
                    {
                        // no title text so this means fsx is in full screen mode
                        // do what ever you need to do here - in my case I send Alt-Enter to flip it back to windowed mode so I can pop up my app
                    }
                }
            }
        }
 

 

  • 3 months later...
Posted

Apologies if I enter this highly technical discussion with a rather simple question:

why isn't the FSUIPC command FULL_WINDOW_TOGGLE working in FSX?

I am using Windows 8.1 (if that matters) and the current FSUIPC 4.939n , registered.

 

I simply would like to add button or a switch to toggle in/out of Full Screen. I just hate the Alt+Enter thing...

 

 

Thanks!

Posted

It doesn't exist in FSX, It's a control for Prepar3d. If you refer to the document "List of FSX and P3D controls.pdf" in your "modules/FSUIPC Documents" folder, the controls marked with a * are for P3D only.

 

For FSX the only way to toggle full screen mode is to send the Alt-Enter key press to the sim.

 

If you want to program a button to do this in the FSUIPC interface you need to assign the control 'Key Press & Release', then in the parameter box write '13+16'. (13 means the return key, +16 means with Alt held down).

 

Paul

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.