• 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.

MSFS20 Simconnect & Menu Bar Icon and Name

Messages
1,025
Country
us-florida
I've been digging through the SDK and examples, searching online and even daring to ask ChatGPT about if there's any code examples to add a menu item to MSFS to launch a simconnect app.

Maybe I've missed it, but a simple example of a simconnect module that:

  • Has a sample menu bar icon & text
  • And once you press it it says "Hello World!"
That's all I need to get started making some stuff... :P
 
If you search on Github for "toolbar" or "uimod", you can ind some old works about this technical point.
uimod-mugz / msfs-toolbar / icon-toolbar can be a key word to start the search on google :cool:
 
Thank you so much Didier. Downloading the code now :D This should help me get the new MSFS Active Fires rebuild back into the sim with an interface. I'll create a fork with empty code for others to be able to build their own solutions and upload it to GitHub and here once I've got it done :D

I'm thinking I can make a little program to help build templates too :D
 
Any luck with this? I found a link to a git project that has rudimentary framework:

TheFlightSimKit

However, I suck at html/JS programming, and all I was able to change was to insert some MSFS2020 UI elements. What I really need is being able to populate lists provided by SimConnect, and execute SimConnect functions through this UI.
 
You should be able to make a menu that appears on screen (like the ATC). These are available in the MSFS SDK:
Code:
SIMCONNECT_ENUM SIMCONNECT_TEXT_TYPE
{
    SIMCONNECT_TEXT_TYPE_SCROLL_BLACK,
    SIMCONNECT_TEXT_TYPE_SCROLL_WHITE,
    SIMCONNECT_TEXT_TYPE_SCROLL_RED,
    SIMCONNECT_TEXT_TYPE_SCROLL_GREEN,
    SIMCONNECT_TEXT_TYPE_SCROLL_BLUE,
    SIMCONNECT_TEXT_TYPE_SCROLL_YELLOW,
    SIMCONNECT_TEXT_TYPE_SCROLL_MAGENTA,
    SIMCONNECT_TEXT_TYPE_SCROLL_CYAN,
    SIMCONNECT_TEXT_TYPE_PRINT_BLACK = 0x0100,
    SIMCONNECT_TEXT_TYPE_PRINT_WHITE,
    SIMCONNECT_TEXT_TYPE_PRINT_RED,
    SIMCONNECT_TEXT_TYPE_PRINT_GREEN,
    SIMCONNECT_TEXT_TYPE_PRINT_BLUE,
    SIMCONNECT_TEXT_TYPE_PRINT_YELLOW,
    SIMCONNECT_TEXT_TYPE_PRINT_MAGENTA,
    SIMCONNECT_TEXT_TYPE_PRINT_CYAN,
    SIMCONNECT_TEXT_TYPE_MENU = 0x0200,
};

SIMCONNECT_ENUM SIMCONNECT_TEXT_RESULT
{
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_1,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_2,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_3,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_4,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_5,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_6,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_7,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_8,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_9,
    SIMCONNECT_TEXT_RESULT_MENU_SELECT_10,
    SIMCONNECT_TEXT_RESULT_DISPLAYED = 0x00010000,
    SIMCONNECT_TEXT_RESULT_QUEUED,
    SIMCONNECT_TEXT_RESULT_REMOVED,
    SIMCONNECT_TEXT_RESULT_REPLACED,
    SIMCONNECT_TEXT_RESULT_TIMEOUT,
};
As for examples on how to implement any of them; you'll get more information out of the P3D SDK docs than the MSFS SDK docs.
 
Hi Max

No, I'm not referring to the MenuAddItem but looking below the MenuItem stuff, Asobo/Microsoft need the usual hard application of boot to posterior because all of the _TEXT_ methods have been deprecated too. You'd think that they'd have the sense to remove any deprecated items from the simconnect.h file but no; that's just too much trouble.

-Dai
 
Ah yea... I tried to get `Text()` working for far too long before giving up because some code I inherited used it. And they weren't marked deprecated yet in the docs.

Hey if they removed them from the API, or maybe, I dunno, generated a compiler warning if you used them, then people would actually know they don't work anymore and might complain (sooner). ¯\_(ツ)_/¯
 
There is no SimConnect in the JavaScript API.. there's just the JS API. ;)
;) no, I get it - but there IS a JS library - Coherent.js (which is a gross misnomer IMO :D). That's how the whole thing works. And there are methods there that connect to SimConnect, but I haven't seen a single shred of sample code on how to use it, or a basic tutorial, except for what I mentioned, some simple UI blocks that can be inserted as a custom menu on the toolbar. SDK Documentation literally has stubs for the functions included. Just function names and blank spaces.

Now I know there are a few "hello world" videos on how to make a few simple overlay displays, but they involve basically hacking into the running code and dissecting it. That's no way to learn.
 
I've been digging through the SDK and examples, searching online and even daring to ask ChatGPT about if there's any code examples to add a menu item to MSFS to launch a simconnect app.

Maybe I've missed it, but a simple example of a simconnect module that:

  • Has a sample menu bar icon & text
  • And once you press it it says "Hello World!"
That's all I need to get started making some stuff... :p

Just my $0.02, sure - you can develop an exe that is a standalone module which, if you run it from the file system, will happily execute and connect to the sim via SimConnect. This may be advantageous in some cases, and sure, you may be able to put together some kind of an UI that executes an external EXE module, although I am not sure if Coherent.js allows for that. But I think the way the SimConnect modules (or, what you call "apps") were meant to function was to be invoked during the startup of the sim. Then, as they are running, you call the module's functions from within the sim, using Coherent.js functionality.

So, from what I understand, you can create DLL or EXE SimConnect modules that can be launched when the sim is started by creating DLL.XML or EXE.XML files (there are samples somewhere on line)

OR

If you want your SimConnect module to be elegantly contained in a package as a component (and thus be processable by Marketplace if you want to go commercial), together with scenery, aircraft, etc. and properly activated when the sim starts, you create a WASM module (there are samples in the SDK)

Then - your module is basically running as a client and listening for the events hat SimConnect server (that functions within the sim) is sending, and processing them. This is how MSFS2020 SimConnect aircraft gauges are set up, but your module doesn't have to be a gauge - it can do anything. For example, you can take a WASM SDK example, which basically detects and informs the user when a flight is loaded, and literally transplant the code from the SimConnect samples (which are set up to create exe modules). The WASM SDK example is just a stub, a VS project template, to get you started. The code (C++ or C#) in WASM and SimConnect SDK samples is identical. The only difference is that the WASM project is set up to use WASM compiler, and it produces WASM executable.
 
If you're referring to SimConnect_MenuAddItem() and related functions, then no, they've been deprecated in MSFS. I've tried... no worky.
<https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_API_Reference.htm#menu>

Or is there some other way?
I think he was talking about the SimConnect_Text() functionality - the way to put a bar with a single line of text near the top of the screen. That is now labeled as deprecated in the docs, yes. Although, I saw a post somewhere with sample code that claimed that they have managed to re-enable it - but I didn't bookmark it, and I can't find it any longer for the life of me. If I find it, I will post a link here.

WRT SimConnect_MenuAddItem() / SimConnect_MenuAddSubItem() - this was a fully functioning menu system that would (obviously) work from SimConnect, allowing users to interact with SimConnect modules. And yes - I sorely miss this functionality. I developed a class that allowed for menus longer than 10 items, with pagination (next/prev) and cascading sub menus. Someone at MSFS2020 Devsupport forum asked why was this deprecated and if it can be re-instated, and the answer from Asobo was, no, no plans to re-instate it, because there is a way more powerful and flexible in-game UI scheme in place (Coherent.js thing)... which I am all for, progress and all - but again - not a shred of an example on HOW to do this, and the documentation still contains only stubs, and that's after 3.5 years of the SDK release.
 
If you want your SimConnect module to be elegantly contained in a package
....
Then - your module is basically running as a client and listening for the events hat SimConnect server (that functions within the sim) is sending, and processing them.

Yes, but your module is now stuck inside the simulator engine sandbox. And using the C++ libs they provide. Which have no sockets and no threads and only a sanboxed file system, to name just a few limitations. The only way to communicate with the outside world is via... SimConnect. So for example to interact with a user of your program, assuming it's not something running inside the sim itself (HTML/JS), you'll still need to use SimConnect to send custom commands to your WASM module and vise versa for getting data back. So at that point you may as well just use SimConnect in your client app directly (unless you want remote Gauge API access, but that's a different issue... see my profile ;-) ).

And if your app is already running in the sim then likely you don't need SimConnect or WASM at all (though there's now a new messaging system feature for communicating directly between JS code and a WASM module/guage).

Cheers,
-Max
 
Yes, but your module is now stuck inside the simulator engine sandbox. And using the C++ libs they provide. Which have no sockets and no threads and only a sanboxed file system, to name just a few limitations. The only way to communicate with the outside world is via... SimConnect. So for example to interact with a user of your program, assuming it's not something running inside the sim itself (HTML/JS), you'll still need to use SimConnect to send custom commands to your WASM module and vise versa for getting data back. So at that point you may as well just use SimConnect in your client app directly (unless you want remote Gauge API access, but that's a different issue... see my profile ;-) ).

And if your app is already running in the sim then likely you don't need SimConnect or WASM at all (though there's now a new messaging system feature for communicating directly between JS code and a WASM module/guage).

Cheers,
-Max
Hold on - I think you lost me there. I LIKE SimConnect. I NEED SimConnect. I WANT SimConnect 😁 All I want is to be able to control my SimConnect module using a nice in-game UI, accessible from the main in-flight toolbar.

Let's take a simple "AI Objects and Waypoints" SimConnect sample as an example. When you press Z, it spawns 4 objects (2 aircraft, a giraffe and a fire truck) at a certain place (SEATAC runway). When you press X, it sends waypoint lists to the objects, and when you press C, it removes the objects.

What I want now is, instead of mapping Z, X and C keys that invoke 3 functions, I want a simple toolbar icon that opens a dialog menu with 3 buttons that call these 3 functions. That's all. I could make this happen easily with SimConnect_MenuAddItem() / SimConnect_MenuAddSubItem().

I got as far as making a custom toolbar button that opens a simple dialog with buttons, but I have no idea how to call functions in my SimConnect module when a button is clicked.
 
All I want is to be able to control my SimConnect module using a nice in-game UI, accessible from the main in-flight toolbar.
Well there may in fact be Coherent hooks or whatever they call them to achieve the aircraft and giraffe (dunno about the truck :). I'm really not that familiar with the JS side, partly due to the wonderful docs. I tried to make a "persistent gauge" at one point which would somehow load with every aircraft (so I could get to their B vars via a WASM gauge) but I had a similar experience to yours.... "now what?"

But to achieve your heart's desire you could... (this may be a dumb idea mind you):

Create a WASM module which does your SimConnect work, which as you said would be pretty much the same as what any other SimConnect client would look like.
Create an HTML/JS UI with the basic buttons or whatnot.
Use the Communication API to talk between the two. It's brand new... what could go wrong?

(Check the devs forums for bugs related to the Comm. API though... did I mention it's new?)

Again, maybe there's a way to hook directly into SimConnect from Coherent, but I've not come across any mention of that until yours. And seems like all the core Coherent stuff is in some DLLs, so no sources to look at... :(

-Max
 
The reason for deprecating the _TEXT_ and MenuItem methods is, AFAICS, they require windows.h which WASM doesn't like. At all.
 
You'd think that they'd have the sense to remove any deprecated items from the simconnect.h file but no; that's just too much trouble.
I just wanted to share a perspective, that this sim is stitched together around 20 year old code that was almost, but not altogether an entirely different sim. I think it would be sort of like walking around in a haunted house and I believe people just don't know what is safe to get rid of.
Now I know there are a few "hello world" videos on how to make a few simple overlay displays, but they involve basically hacking into the running code and dissecting it. That's no way to learn.
Actually, the "replace HTML gauge" tutorial instructs us to temporarily overwrite a default gauge using the VFS, the placement gauge will of course cease to exist when we close the Project Editor, the idea being that we learn how to manipulate the various .css, .html and .js files to see those changes happen in real time to our replacement gauge. This is the same process we use to create ad addon livery, or basically anything that supplants default content. The complementary tutorial, "creating an HTML gauge," shows us the steps to create and implement a gauge from "scratch," however the intentionally overlapping tutorials are not kept distinct due to what I can only call "imprecise language," the PID tutorial is much clearer in that regard.

It seems a little odd to have the two tutorials side by side, learning "replacement" before "creation" seems to make sense for someone who is just editing gauges in default aircraft and how many people do only that.
 
Last edited:
I just wanted to share a perspective, that this sim is stitched together around 20 year old code that was almost, but not altogether an entirely different sim. I think it would be sort of like walking around in a haunted house and I believe people just don't know what is safe to get rid of.
Ah; that's why I specified simconnect.h and not simconnect itself. By removing the method prototype (or whatever the mot-de-jour is) from the header file, you effectively remove access to the underlying code without touching that code, so no-breaky-crappy.
 
The reason for deprecating the _TEXT_ and MenuItem methods is, AFAICS, they require windows.h which WASM doesn't like. At all.
Just curious what you mean... the HANDLE and DWORD types?
For Win types there's the <MSFS/MSFS_WindowsTypes.h> include available in the SDK.

And for a reference for Text()/menu stuff I had to go to P3D... <https://www.prepar3d.com/SDKv4/sdk/simconnect_api/references/general_functions.html#SimConnect_Text>

I was actually working on some FSX-specific stuff recently and was wondering how the heck one is supposed to get to that version of SimConnect SDK docs. Seems like all traces have been wiped out :rolleyes:
The closest I've come is of course the P3D docs (v4 I guess matches most closely?) and the old ESP docs (and I'm not sure I have no idea how closely these match actual FSX sp2 features).
 
Back
Top