Jump to content


Photo

[AHK_L] Additional menu Cmd to retrieve HMENU


  • Please log in to reply
3 replies to this topic

#1 just me

just me
  • Members
  • 1175 posts

Posted 30 June 2012 - 08:17 AM

As lastly asked in this post, wouldn't it be nice to have a command like Menu, MenuName, New, OutputVarHMENU yielding the menu handle (HMENU)?

#2 Lexikos

Lexikos
  • Administrators
  • 8839 posts

Posted 01 July 2012 - 04:19 AM

"Wouldn't it be nice" is a phrase to avoid in the Suggestions forum if you want me to actually implement something. Adding a "New" sub-command just so that you can get a HWND isn't very intuitive. If you can come up with an appealing syntax for retrieving the HWND of a new or existing menu, I may implement it.

*resists temptation to post Beach Boys youtube video...

#3 just me

just me
  • Members
  • 1175 posts

Posted 01 July 2012 - 07:58 AM

"Wouldn't it be nice" is a phrase to avoid in the Suggestions forum if you want me to actually implement something.

Well, the English language still has some secrets for me. I just tried to ask politely. As a second try:
..., I suggest to implement a command like Menu, MenuName, New, OutputVarHMENU yielding the menu handle (HMENU).

Adding a "New" sub-command just so that you can get a HWND isn't very intuitive.

Hmmm, I was thinking about the Gui, New sub-command when suggesting this. The New menu sub-command could act like the New GUI sub-command:Creates a new menu. Any existing menu with that name is destroyed. The menu handle (HMENU) is stored in OutputVarHMENU (P3).

If you can come up with an appealing syntax for retrieving the HWND of a new or existing menu, I may implement it.

Since all Menu commands only deal with the script's own menus, I don't see the need to get the HMENU of an existing menu. Both CreateMenu() and CreatePopupMenu() API-functions don't have parameters and return the HMENU. I assume it won't be changed afterwards. So it may be more intuitive to call the new sub-command Create.

BTW: From their start I've never been a fan of the "Beach Boys". And, who has chosen the new color for Mods? Any dealings with the German Telekom?

#4 Lexikos

Lexikos
  • Administrators
  • 8839 posts

Posted 01 July 2012 - 12:39 PM

Creating a new menu should not be the only way to retrieve its handle. Why should the script store the handle when it can be simply retrieved by name each time it is needed? AutoHotkey already stores the handle internally. Consider also that the code retrieving the handle mightn't be in control of how the menu is created. For example, it could be a library function providing additional menu-related functionality. Actually, that's probably the main use for this capability.

Excluding this "hwndOutputVar", a "New" command doesn't seem to have much value. Gui New was created primarily so that library functions could create a GUI without reserving a name or number. There seems to be less need for this with menus. Additionally, since the Menu command doesn't combine the name with the sub-command the way the Gui command does, creating an anonymous menu would be kind of awkward. Compare:
Gui New, hwndVar
Menu,, New, hwndVar
Lastly, there is no concept of a "default" menu, so you would need to specify %Var% for each menu command thereafter.

Well, the English language still has some secrets for me.

Your English is fine, and you're free to ignore my gripe. Whether true or not, the immediate impression I get whenever I see that phrase is that the person writing it didn't think their idea through and consider whether it is actually useful or worthwhile.

BTW: [1] From their start I've never been a fan of the "Beach Boys". [2] And, who has chosen the new color for Mods? Any dealings with the German Telekom?

[1] Neither have I; they're long before my time. I find the song annoying, after hearing the lottery ad version too many times.
[2] I persume it was polyethene, because I can't imagine who else would have made any change to the site, and because he was online when I noticed the change happen.