Can't seem to make this Drop Down List behave correctly

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
A_Perry_1984
Posts: 76
Joined: 07 Dec 2018, 12:08

Can't seem to make this Drop Down List behave correctly

07 Dec 2018, 12:22

Hello fellow members. Could someone please assist me?

I have been attempting to create a drop down with a list of names. When I select a name, I want to store it to a variable, rearrange the drop down list beginning with my stored name as the first choice.

The problem is whenever I select the name from the list and submit, the list becomes redundant. In other words I see the names appear more than once.

I can't seem to figure out why. It must be something basic I need to change. Also I may not be doing this in the most efficient manner to begin with. If there is a completely better way to do this, I would appreciate your input. Thanks again.

Code: Select all

#SingleInstance, force
names_list =
(
missy
alex
michelle
cleo
jason
)
gosub GetMyList
gui, add, DropDownList, sort vName w155, %List1%
gui, add, button, default gGo, Go
gui, show,AutoSize
return

GetMyList:
if (Name = "")
		Name = alex
loop, parse, names_list, `n
{
	;MsgBox % A_LoopField
	if Not instr(A_LoopField, Name)
	list .= A_LoopField "|"
}
List1 = %Name%||%list%
msgbox  The Drop Down List order is:`n%List1%
return
Go:
gui, submit, nohide
gosub GetMyList
;GuiControl,,?
return

GuiClose:
ExitApp
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Can't seem to make this Drop Down List behave correctly

07 Dec 2018, 13:06

Reset the list before adding inside the loop, like this:

Code: Select all

GetMyList:
List := "" ; <-- here
if (Name = "")
I hope that helps.
A_Perry_1984
Posts: 76
Joined: 07 Dec 2018, 12:08

Re: Can't seem to make this Drop Down List behave correctly

10 Dec 2018, 06:38

Thank you! I can't believe it was so simple.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, mikeyww and 206 guests