Author Topic: Spad.next - Anyone have a script/snippet to OPEN and CLOSE the menu  (Read 1512 times)

mustang60348

  • Newbie
  • *
  • Posts: 2
As the title says, I can OPEN the menu but not close it from SPAD.next via the FSDT_GSX_MENU_OPEN = 1 but setting it to 0 does not close it, tried -1 , -2 etc.

virtuali

  • Administrator
  • Hero Member
  • *****
  • Posts: 51426
    • VIRTUALI Sagl
Re: Spad.next - Anyone have a script/snippet to OPEN and CLOSE the menu
« Reply #1 on: February 25, 2023, 05:47:52 pm »
You should never try to use undocumented variables to drive GSX, both because we might change them at any time ( we'll surely do as soon we'll have a better way in the SDK to interact with the Html menu ), but also because you cannot possibly know how the really work...because they are undocumented, and they are undocumented precisely for the above reasons.

The FSDT_GSX_MENU_OPEN is only a temporary variable that is used to trigger some communication between the Html menu, the GSX WASM module and the Couatl scripting engine that runs the actual GSX code, so it's just a (convoluted, but it's the only way), to allow interaction between the Html menu and Simconnect, which is not otherwise possible so, in your case, your effort to set the variable to something were nullified by the fact the GSX WASM module, as soon it recognizes the variable was set to 1, will immediately set it back to 0, together with a custom Simconnect event to communicate to GSX/Couatl the menu has been opened, so it's just a semaphore/mutex that works only in that direction.

In addition to that, you cannot open the GSX menu without it being already Active, which can only work if you open it first from the Toolbar menu OR if you end a flight with the icon Active, return to the main menu then start another flight, so the menu will automatically open on the 2nd flight.

If you try to set the variable to 1 when the toolbar icon is not Active ( dark ), nothing will happen. But if the toolbar icon is already Active, you can Open AND Close the menu with the HOTKEY so, considering you will still need to have the icon Active in any case, why not just using the Hotkey to open/close the menu ?

This method will be more reliable because, while we can possibly ( and we will, when possible ) change anything the way the menu works, we'll surely always have some hotkey.

Now, if you really want to go the fancy route and ignore my warning about your code being broken by future GSX updates, you can use the following expression to close the menu AS IF you clicked the X icon:

3 (>K:EXTERNAL_SYSTEM_TOGGLE)

But be warned, this can change at any time, that's why we never documented.
« Last Edit: February 25, 2023, 05:50:53 pm by virtuali »

mustang60348

  • Newbie
  • *
  • Posts: 2
Re: Spad.next - Anyone have a script/snippet to OPEN and CLOSE the menu
« Reply #2 on: February 25, 2023, 05:56:38 pm »
I have decided to go the other route. Using the shortcut key Control Shift F12 to open, then sending the keypress for what I want to select seems to work better.

virtuali

  • Administrator
  • Hero Member
  • *****
  • Posts: 51426
    • VIRTUALI Sagl
Re: Spad.next - Anyone have a script/snippet to OPEN and CLOSE the menu
« Reply #3 on: February 25, 2023, 06:00:32 pm »
I have decided to go the other route. Using the shortcut key Control Shift F12 to open, then sending the keypress for what I want to select seems to work better.

That's surely a better approach: since you need to send key presses anyway to make a 0-9 choice, and you need to have the icon Active to receive the GSX hotkey in any case, it's much easier to just send the hotkey as well to open/close the menu.

Seth2413

  • Jr. Member
  • **
  • Posts: 62
Re: Spad.next - Anyone have a script/snippet to OPEN and CLOSE the menu
« Reply #4 on: February 25, 2023, 11:18:37 pm »
As the title says, I can OPEN the menu but not close it from SPAD.next via the FSDT_GSX_MENU_OPEN = 1 but setting it to 0 does not close it, tried -1 , -2 etc.

Have you looked at flow pro - has a widget to open GSX in it, very handy.