function containing GuiControl doesn't work with hotkey

拟墨画扇 提交于 2019-12-11 06:39:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!