Use menu with different handlers? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Use menu with different handlers?

Post by lexikos » 14 Aug 2022, 20:00

You can use variables or expressions with virtually every parameter of every command... It is shown throughout the documentation, and explained in a few places.

For Menu Add specifically, it explicitly says that LabelOrSubmenu can be "a single variable reference containing a function object. For example, %FuncObj% or % FuncObj." This is in the paragraph that swagfag linked to. However, you don't have to use a function object; the variable can contain whatever value you would be passing literally (a function or label name).

elbitjusticiero
Posts: 78
Joined: 06 May 2017, 11:07

Re: Use menu with different handlers?

Post by elbitjusticiero » 15 Aug 2022, 06:50

lexikos wrote:
14 Aug 2022, 20:00
You can use variables or expressions with virtually every parameter of every command... It is shown throughout the documentation, and explained in a few places.

For Menu Add specifically, it explicitly says that LabelOrSubmenu can be "a single variable reference containing a function object. For example, %FuncObj% or % FuncObj." This is in the paragraph that swagfag linked to. However, you don't have to use a function object; the variable can contain whatever value you would be passing literally (a function or label name).
Yes, this is what I didn't know. Function objects are more complicated than just simple labels. I ended up using a label that I keep together with the "save to favs" function, and not the "build the menu" function. It works like a charm. Thanks again!

Post Reply

Return to “Ask for Help (v1)”