Jump to content
The simFlight Network Forums
DLuis

LUA Script and GSX Menu

Recommended Posts

Hi,

I'm trying to make Lua script to automatically handle all the GSX services.

It's possible to extract the text from the GSX Menu to know if it's visible or even better, possible to get the services page?

I'm asking this because I don't want to use timers to press the keys so that the menu barely appears.

Using last 5.14 and P3Dv4.1 without WideFS

GSX.jpg

Share this post


Link to post
Share on other sites
2 hours ago, DLuis said:

It's possible to extract the text from the GSX Menu to know if it's visible or even better, possible to get the services page?

Is the text actual ASCII characters, or part of an Image? If it is a  character string then of course you can using the standard Lua string library functions to search for specific words or phrases, and thus act upon them. Refer to string.find.

Image recognition is far too complex. I doubt if Lua is the right language for that, and I wouldn't know how to even begin!

That image looks like it is from the EFC program which is in Beta at present, from the ProSim forum. Correct?

On P3D4 you can get texts as above, in searchable string form, from SimConnect directly, or using FSUIPC + WideClient. Then run your Lua program in the client.

Pete

 

 

Share this post


Link to post
Share on other sites
13 hours ago, Timonier said:

Perhaps those two links will give an idea :

https://www.avsim.com/forums/topic/542078-gsx-library-sept-2018/

Certainly for the doors

and

https://www.avsim.com/forums/topic/512119-new-linda-309-32-64-bit-compatible-18-sep-2018/

Hope this help

Best Regards

Marc

UPDATE : sorry it's only for the GSX doors 😧

Sorry, those links tell me that LINDA does it for you, for certin aircraft at least. What is it you now want to do? The image you posted looks like one from an iPad or Android running EFC for ProSim.

Pete

 

Share this post


Link to post
Share on other sites

Hello,

Sorry for my delay answer and thanks a lot for the replies.

This image is a print from P3D main window with "panel only" view (the reason for the black background), as nothing to do with Prosim, EFC or network gauge. It's just GSX Menu in P3D.

Yep, I'm using the new L:Vars of GSX to check the state of the services.

I'm using this code in lua to call for deboarding and works great:

            repeat 
                    ipc.keypressplus(123, 3, 4)
                    ipc.sleep(1000)
                    ipc.keypressplus(49, 0, 4)
            until DEBOARDING < 2

DEBOARDING = L:VAR (FSDT_GSX_DEBOARDING_STATE)

but not for pushback because are more option after selected, so I have to delay the keypress. To be safe, the delay must be long (but the menu stays there...). 

I just need a flag that tells me that the GSX Menu is open to make the keypress just after the menu appears, this is my goal.

 

In the Lua Library, I notice the event.textmenu, but only works in the WideClient.

Share this post


Link to post
Share on other sites
59 minutes ago, DLuis said:

I just need a flag that tells me that the GSX Menu is open to make the keypress just after the menu appears, this is my goal.
In the Lua Library, I notice the event.textmenu, but only works in the WideClient.

Actually, I don't see any reason I cannot add it to the FSUIPC5 Lua event library. There just never seemed to be any point before. I can implement that for the next 5.14 update.

So, you don't read the text of the menus, you just relay on the L:Vars? The event.textmenu facility would give you texts as well, not just for menus but also Simconnect messages and contents of message windows.

Pete

 

Share this post


Link to post
Share on other sites

Hi Pete,

 

Yes, I just rely on L:Vars, not in the text of the GSX Menu.

I tried the event.textmenu, but it gives me one a "null" error, so i see that this is a WideClient function (it's documented, my bad).

Well, if you are able to do that, for me would be great and be very appreciated, because my goal is to do something like this to call boarding/deboarding and all other stuff:

                    ipc.keypressplus(123, 3, 4) -- CTRL + Shift + F12

                    while GSXMenuflag == 0 do -- Wait until GSX Menu appears

                              ipc.sleep(100)

                    end
                    ipc.keypressplus(49, 0, 4) -- Press 1

This would make almost one invisible GSX Menu 🙂

 

Share this post


Link to post
Share on other sites
4 minutes ago, DLuis said:

Well, if you are able to do that, for me would be great and be very appreciated, because my goal is to do something like this to call boarding/deboarding and all other stuff:

                    ipc.keypressplus(123, 3, 4) -- CTRL + Shift + F12

                    while GSXMenuflag == 0 do -- Wait until GSX Menu appears

                              ipc.sleep(100)

                    end
                    ipc.keypressplus(49, 0, 4) -- Press 1

This would make almost one invisible GSX Menu 🙂

With event.textmenu you'd be able to read the menus, the item placing in the menu itself, and, possibly just as importantly, the textual prompts outside the menu. A plug-in could handle other programs with menus too, whether they have L:Vars you can use or not.

So, I've decided it might be very useful and so I am adding this capability now. It will be in the next update for FSUIPC5 (only).  Not sure when yet -- there are other things we are doing -- but probably within days rather than weeks.

Pete

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Pete,

 

What can i say, thanks a lot for this new feature. For me FSUIPC5 it's more than fine 😄 

Days or weeks doesn't matter, take your time.

 

Thanks again for the help.

Share this post


Link to post
Share on other sites

Hello Pete,

 

I've downloaded last version, but I can't find anything in the documentation for check if the GSX menu is Active or not.

Can you tell me what the reference in lua to check this?

Share this post


Link to post
Share on other sites
1 hour ago, DLuis said:

I've downloaded last version, but I can't find anything in the documentation for check if the GSX menu is Active or not.

There's nothing to check "GSX menu" specifically. You just use event.textmenu and receive the text from whatever menu there is, when it displays.

1 hour ago, DLuis said:

Can you tell me what the reference in lua to check this?

event.textmenu in the event library descriptions. It's been in there for a long time, but enhanced for P3D4 since FSUIPC 5.13. So I'm not sure what the "last version" you refer to is?

Note that there are minor updates in the document in the 5.15 release too, but please check the first paragraph of the document  It should say "(for FSUIPC5, version 5.15 and later, ...". The first day of the 5.15 release actually had the previous versions of the documents installed, for the very latest you'd need to clear your cache (F5 I think) and download again. But this is not necessary for this facility.

Pete

 

 

Share this post


Link to post
Share on other sites

Hi Pete,

 

Last version for me is 5.15, but I was looking for something different and didn't notice that event.textmenu now works without WideFS

I will try this facility and give feedback later.

 

Thanks a lot for all your work and effort on this. 

Share this post


Link to post
Share on other sites

Pete,

 

Little help please 😞

Trying this facility with only this lua script:

function GSXMenu(type, colour, scroll, delay, id, n, msgs)
    ipc.log("Menu Opened")
end

event.textmenu(0, "GSXMenu")

 

but I'm having this error starting the script:

*** LUA Error: ...GSX.lua:5: unexpected symbol near 'ï'

Share this post


Link to post
Share on other sites
22 minutes ago, DLuis said:

Trying this facility with only this lua script:

function GSXMenu(type, colour, scroll, delay, id, n, msgs)
    ipc.log("Menu Opened")
end

event.textmenu(0, "GSXMenu")

 

but I'm having this error starting the script:

*** LUA Error: ...GSX.lua:5: unexpected symbol near 'ï'

You have some extra characters in your code, non-ASCII ones I think -- one character or more after the last ).

Delete the line completely and re-type it.

BTW you realise that using 0 to don't just get Menus, you also get Text Messages. For menus only you need 2.

Pete

 

Share this post


Link to post
Share on other sites

Pete,

 

Totally right, copy/paste did put some non-ASCII in the code. About the types, this it's just for testing probably just need 2 for menu popup.

Now i don't have errors, but also nothing happens when opening GSX menu...  I've "Waiting for an event in "...GSX.lua" in the log, but no "Menu Opened" or function called.

Using last version of GSX and FSUIPC 5.15.

Share this post


Link to post
Share on other sites
1 hour ago, DLuis said:

Using last version of GSX and FSUIPC 5.15.

Which version of P3D4? Your script is working fine here. Maybe add a log  entry when you invoke the event.textmenu function, just to check that your Lua is really running.

To check that the facility is working add the following lines to the [General] section of FSIOPC5.INI:

Debug=Please
TestOptions=X8000

This will give entries for menus like this (this is a test menu only):

  1498655 ### TEXT: 512 (Menu) From SimC, Duration 0.00, Flags 00000000, Len=81
  1498655      SimConnect Text Menu
  1498655      Choose which item:
  1498655      Item #1
  1498655      Item #2
  1498655      Item #3
  1498655      Item #4
  1498655      Item #5
  1498655 ***DISP*** Text/menu type 2 broadcast
  1498655 TextMenu Displayed


That last line is from your script.

When I selected an item from the menu I got this logged:

  1578262 ### TEXT_DESTROY: 512 (Menu) Result: 2, Flags 00000000
  1578262 ***DISP*** Text/menu type 2 clear broadcast
  1578262 LUA.0: Menu Opened


so it gets called then, too, when the menu is cleared.

Pete

 

Share this post


Link to post
Share on other sites

Hi Pete,

Still using version 4.1

 

If the script works fine with you, means that probably the problem is in P3D4 version. I really don't have anything with the Debug=Please and TestOptions=X8000

I will try to update P3D and then use the script again.

 

Thanks a lot for your time Pete, really appreciate for your effort. 

 

Share this post


Link to post
Share on other sites
12 minutes ago, DLuis said:

Still using version 4.1

 

If the script works fine with you, means that probably the problem is in P3D4 version.

I think in was added in P3D later -- 4.2 with errors, fixed to indicate clearance in 4.3. 

Sorry, this should really be mentioned in the Lua PDF.  I obviously thought no one would stick with such an old version of P3D4. I'll amend it for the next update.

I can very strongly recommend P3D4.4. Excellent version, very robust, good performance, outstanding graphics.

Pete

 

Share this post


Link to post
Share on other sites

Hi Pete

 

Please don´t sorry. The problem is with me, I need to move forward.

I'm not going to give up, after the update I will try again this facility to make the key press a son as the GSX Menu appears and give the feedback to you.

 

Thanks a lot for this amazing piece of software and for all your attention and effort to the community.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

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