问题
test() {
GuiControl, , abc, 123456789
}
GUI New
GUI Add, ListBox, xm y+m w100 h100 vabc
GUI Add, Button, xm y+m w60 h30 grun, Add
GUI Show, Autosize
Return
run:
test()
return
GuiClose:
ExitApp
!1::
test()
MsgBox 1
return
I wanna call test() when I press the key Alt + 1, But my code above doesn't work. Only the message '1' is output.
Obviously I seem to be misunderstanding something.. How to solve this problem?
回答1:
This displays a GUI window containing a list control and appends a row with "123456789" to it when ALT-1 is pressed
test() {
GuiControl Alpha:, abc, 123456789
}
GUI Alpha: New
GUI Add, ListBox, xm y+m w100 h100 vabc
GUI Add, Button, xm y+m w60 h30 grun, Add
GUI Show, Autosize
Return
run:
test()
return
GuiClose:
ExitApp
!1::
test()
return
GUI commands within hotkeys will refer to different gui threads by default. You can use a GUI Name (Alpha:
in the above example) to specify an existing GUI window.
来源:https://stackoverflow.com/questions/46730914/function-containing-guicontrol-doesnt-work-with-hotkey