Question

I am not an expert but try to figure it out about ~6 hours now, I have a selection window with 2 items, and whatever what i choose it say i choose No1 item. Later on i replace nr1, nr2, with actions if the selections could working. Please help! I assume i use wrong code at MyListbox1.

Gui, Add, ListBox, vMyListBox1 gMyListBox1 w100 r10
{
    GuiControl,, MyListBox1, Item1|Item2
}
Gui, Show
return

MyListBox1:
if A_GuiEvent <> DoubleClick
    return
GuiControlGet, MyListBox1, %Item1%
GuiControlGet, MyListBox1, %Item2%
IfMsgBox, %Item1%
MsgBox, MsgBox You entered 1
    return
IfMsgBox, %Item2%
MsgBox, MsgBox You entered 2
Return

GuiClose:
GuiEscape:
ExitApp
Was it helpful?

Solution

Like this?

Gui, Add, ListBox, vMyListBox1 gMyListBox1 w100 r10, NotePad|x
Gui, Show
return

MyListBox1:
if A_GuiEvent <> DoubleClick ; If not double click stop
    Return
GuiControlGet, MyListBox1 ; Get current value of MyListBox1 variable
If (MyListBox1 = "NotePad") ; If MyListBox1 contains NotePad
    Run, NotePad.exe
Else If (MyListBox1 = "x") ; If MyListBox1 contains x
{
    Send, !{Esc} ; Need to switch back to previous application since GUI is in focus and you would send the data to your own GUI
    Sleep, 100 ; Wait a little while, so that the other application can be in focus
    Send, x ; You could have used Send, %MyListBox1%, since MyListBox1 contains x
}
Return

GuiClose:
GuiEscape:
ExitApp
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top