简单的功能问题,如何处理参数

simple function issue, how to handle parameter

我在编写脚本,并使用超级基本的图形用户界面来跟踪发生的事情。 因为我用它记录了每一步,所以我的代码被 gui gui gui gui 等杂乱无章,我想清理它。

所以每次我做某事时都使用:

Gui Destroy
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner  ; +Owner avoids a taskbar   button.
Gui, Add, Text,, script is starting now
Gui, Show, x-500 y400 NoActivate  ; NoActivate avoids deactivating the currently active window.

我想使用一个函数来调用 gui 并给它显示信息,如:

infodisplay(hello world)


infodisplay(msg) 
{
Gui Destroy
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner  ; +Owner avoids a taskbar button.
Gui, Add, Text,, msg
Gui, Show, x-500 y400 NoActivate  ; NoActivate avoids deactivating the currently active window.
}

但我得到的不是带有 hello world 的文本字段,而是带有 msg 的文本字段:( 我阅读了两次帮助文件,但我真的不知道如何处理函数。

我可以用这个吗?这行得通吗?这个想法是

some code ....
infodisplay(step 1)

more code
infodisplay(step 2)

使用%s

infodisplay(msg) 
{
    Gui Destroy
    Gui, +AlwaysOnTop +Disabled -SysMenu +Owner  ; +Owner avoids a taskbar button.
    Gui, Add, Text,, %msg%

(您可能想查看 http://autohotkey.com/docs/Variables.htm

对于 gui 的编辑,http://autohotkey.com/docs/commands/GuiControl.htm 您可能也会感兴趣。

祝一切顺利,