I try to get a dictionary value by the selected item of a TextMenu.
Code: Select all
dict := { "A" : "123", "B" : "345", "C" : "678" }
txt := dict[A_ThisMenuItem]
MsgBox % txt
Any suggestions?
Code: Select all
dict := { "A" : "123", "B" : "345", "C" : "678" }
txt := dict[A_ThisMenuItem]
MsgBox % txt
Code: Select all
#Requires AutoHotkey v1.1.33
dict := { "A" : "123", "B" : "345", "C" : "678" }
Menu menu, Add, A
Menu menu, Add, B
Menu menu, Show
Return
A:
B:
txt := dict[A_ThisMenuItem]
MsgBox % txt
Return
Code: Select all
#Requires AutoHotkey v2.0
dict := Map("A", 123, "B", 345, "C", 678)
m := Menu()
m.Add("A", go)
m.Add("B", go)
m.Show
go(ItemName, ItemPos, MyMenu) {
MsgBox dict[ItemName]
}