| View previous topic :: View next topic |
| Author |
Message |
usernotfound Expert Cheater
Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Nov 03, 2016 4:20 am Post subject: How can I select a menu option from CE with Lua |
|
|
| I need a button in my trainer that can select one of the menu options from the main CE window that I populated myself, for example Plugins > Execute plugin .dll or Extras > Execute plugin .lua (so basically like a key shortcut but with an OnClick event instead), is there a way I can do this?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
Posted: Thu Nov 03, 2016 4:40 am Post subject: |
|
|
if you gave the menuitem a name property you can basically do getMainForm().menuitemname.doClick()
if not, then you have to walk through the menu list manually looking for the caption. ( the getMainForm().MainMenu.Items tree)
or if you added the menuitem with lua, you can just keep a reference to it somewhere so your button can find it
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
usernotfound Expert Cheater
Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Thu Nov 03, 2016 5:35 am Post subject: |
|
|
Thanks DB getMainForm was what I was looking for.
| Code: | function PluginsClick()
getMainForm().Menu.Items[7][0].doClick()
end |
|
|
| Back to top |
|
 |
paul44 Expert Cheater
Reputation: 2
Joined: 20 Jul 2017 Posts: 206
|
Posted: Fri Nov 20, 2020 9:21 am Post subject: Accessing menu_item by name... |
|
|
@Dark Byte: tried and... error-ed... (did try some other 'index' approaches too)
I assume this is what you mean with giving it a name (see below)? (even tried without apostrophes (CE did not complain), but still no-go...?)
ps: the "array_index" method works fine, but that is not what I really want (~ readability .. future_ce_updates)
[code]
OpenFilemenuitem = createMenuItem(mmenu)
OpenFilemenuitem.Caption = sMenuItem4
OpenFilemenuitem.OnClick = OpenFileDialog
OpenFilemenuitem.Name = 'LaunchGame'
mi.add(OpenFilemenuitem)
...
--getMainForm().Menu.Items[11][2].Enabled = false (...works fine)
--OpenFilemenuitem.Enabled = false (...works fine, after some serious T&E )
getMainForm().LaunchGame.Enabled = false
OR
getMainForm()['LaunchGame'].Enabled = false
OR
getMainForm().OpenFilemenuitem.Enabled = false
[/code]
=> ...attempt to index a nil value (field 'OpenFilemenuitem') (~in that last case)
Directly related to this: is it possible to easily "remove" a (main) menuItem. Practically: one adds a new menu (with some (sub)menu_items) to the MainMenu. But depending some "flag_status", this menu should be shown or not. Tried 'nil/destroy()'-ing that menu_item, but nogo. However, this seems to work on any of the submenu_items.
(i'm beginning to think, it is more a matter of getting the Mainmenu 'refresh'-ed somehow...?)
ps: just checked the item's Propertylist: perhaps I could use the 'Visible' property for this purpose...
FYI: logically, my menuItem would be at [5][x] (in Mainmenu], but this was/is not the case. Ran a script from #panraven, which builds a list of all menu_items (easypeasy )...
|
|
| Back to top |
|
 |
|