Multible add in menu

Get help with using AutoHotkey and its commands and hotkeys
Calvin
Posts: 46
Joined: 22 Jul 2016, 01:11

Multible add in menu

28 Nov 2019, 13:23

Insted of the code:

Menu, Submenu1, Add, Item1, MenuHandler
Menu, Submenu1, Add, Item2, MenuHandler
Menu, Submenu1, Add, Item3, MenuHandler
Menu, Submenu1, Add, Item4, MenuHandler
Menu, Submenu1, Add, Item5, MenuHandler

I want to use this:

Code: Select all

x := 0
loop 5
{
	x += 1
	Menu, Submenu1, Add, Item.x, MenuHandler
}
It dont work - help.

[Mod edit: Topic moved to 'Ask For Help']
User avatar
Delta Pythagorean
Posts: 567
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: Multible add in menu

28 Nov 2019, 14:08

A. This is Scripts and Functions, this is the section you'd go to, to post your code that you created that would benefit the community. The section you're looking for is Ask for Help.
B. To fix this, you have to understand how variables work. Look here.
C. To actually fix this and make it work, use the following:

Code: Select all

Loop, 5
{
	; Loop has a variaety of different variables ot use instead of creating your own to increment every time you go through a loop.
	; A_Index is the amount of times the code has been executed so far.
	Menu, Submenu1, Add, % "Item" A_Index, MenuHandler
}

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.18362
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Delta#3324

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], songdg, Xtra and 55 guests