• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX:SE Taking a Screenshot

Messages
7
Country
us-florida
I have tried taking automated screenshots of FSX:SE several different ways in my C++ program. The automated screenshot is supposed to take place after I set several flight variables through SimConnect such that I can take a screenshot of those gauges at those positions for use elsewhere. I have tried using emulated keypresses using SendInput() from the Windows library to trigger PrtSrc, the Win+Alt+PrtSrc used in the Xbox bar for screenshots, and F12 to trigger a Steam screenshot. For some unknown reason, seperate programs running those emulated keypresses produce the desired effect outside of FSX, but when I try to use it in the FSX window, all of the keypresses are sent, but nothing occurs afterward. Here is a code snippet from my most recent test showing the Dispatch function. Everything except for the keypresses work as expected.
C++:
void CALLBACK MyDispatchProcSD(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
    HRESULT hr;
   
    switch(pData->dwID)
    {
        case SIMCONNECT_RECV_ID_EVENT:
        {
            SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;

            switch(evt->uEventID)
            {
                case EVENT_SIM_START:
                    {
                       
                        hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_6, SIMCONNECT_STATE_ON);
                    }
                    break;


                case EVENT_6:
                    {
                        SIMCONNECT_DATA_INITPOSITION Init;
                        Init.Altitude   = 5000.0;
                        Init.Latitude   = 47.64210;
                        Init.Longitude  = -122.13010;
                        Init.Pitch      =  0.0;
                        Init.Bank       = -1.0;
                        Init.Heading    = 180.0;
                        Init.OnGround   = 0;
                        Init.Airspeed    = 60;
                        hr = SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_6, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(Init), &Init );
                        printf("\nEVENT_6 received and data sent");
                        hr = SimConnect_TransmitClientEvent(hSimConnect, 0, EVENT_7, 0, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
                        Sleep(25000);

                        INPUT input[1] = {};
                        input[0].type = INPUT_KEYBOARD;
                        input[0].ki.wVk = VK_LWIN;
                        UINT test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;
                        Sleep(250);

                        input[0].ki.wVk = VK_MENU;
                        test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;
                        Sleep(250);

                        input[0].ki.wVk = VK_SNAPSHOT;
                        test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;
                        Sleep(250);

                        input[0].ki.wVk = VK_LWIN;
                        input[0].ki.dwFlags = KEYEVENTF_KEYUP;
                        test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;
                        Sleep(250);

                        input[0].ki.wVk = VK_MENU;
                        test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;
                        Sleep(250);

                        input[0].ki.wVk = VK_SNAPSHOT;
                        test = SendInput(ARRAYSIZE(input), input, sizeof(INPUT));
                        std::cout << test << std::endl;

                       

                    }
                    break;

                default:
                    break;
            }
            break;
        }

        case SIMCONNECT_RECV_ID_QUIT:
        {
            quit = 1;
            break;
        }

        default:
            printf("\nReceived:%d",pData->dwID);
            break;
    }
}

Does anyone know why this doesn't work? Pressing the keys manually also produces the desired effect. It is only emulated keypresses that do not work.
 
The screenshot key in FSX is 'v'. You should be looking at how SimConnect supports sending events (including key presses).
 
Last edited:
Back
Top