Why is ChooseMenuItem sometimes not working?

31 views Asked by At

Based on the dm-script manual, ChooseMenuItem is used to simulate the click of the corresponding menu. I have tried these 3 commands as below, but only the first one can work. This is due to the wrong usage of this command or some limitation?

ChooseMenuItem("Help","User Mode","Power User")
ChooseMenuItem("Window","Floating Windows","Output")
ChooseMenuItem("Process","","FFT")
1

There are 1 answers

1
BmyGuest On BEST ANSWER

The command doesn't really simulated a click, it rather attempts to find the according menu entry and calls the associated function. But yes, there are limitations to what the command can do. (In particular since GMS 3.x which had a UI overhaul that changed some menus.)

Having said that, I've just tested the three commands above on my machine.

  • ChooseMenuItem( "Help" , "User Mode" , "Regular" ) // or "Power User" or "Service"
    Works as it should.

  • ChooseMenuItem( "Window" , "Floating Windows" , "Output" )
    Does not work. I think this is one which isn't working because the way GMS 3.6 changed its UI.
    But there really is no need for that one neither, as you can use: OpenOutputWindow() directly.

  • ChooseMenuItem("Process","","FFT")
    works, but there you have to be careful: The menu item is only available (not greyed out) when a suitable image window is front most. With the script-window front-most, the command is not available and the script hence fails. You may want to do something like the below, if you run the script form the script editor window:

GetFrontImage().SelectImage()
ChooseMenuItem("Process","","FFT")

In general, I would advice against using ChooseMenuItem() in most situations, in particular when the according functionality is accessible directly.