包含 GuiControl 的函数不适用于热键

function containing GuiControl doesn't work with hotkey

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

我想在按下 Alt + 1 键时调用 test(),但是我上面的代码不起作用。仅输出消息“1”。

显然我似乎误会了什么..如何解决这个问题?

这会显示一个包含列表控件的 GUI window,并在按下 ALT-1 时向其附加一行“123456789”

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 命令将引用不同的 gui 线程。您可以使用 GUI Name(上例中的 Alpha:)来指定现有的 GUI window.