按钮自动激活

时间:2019-05-02 10:31:58

标签: autohotkey

我不太清楚为什么,但是每当我运行ahk文件时,按钮都会自动激活。 (我放置了GuiClose: ExitApp,以便它不会无限刷新)。另外,还有更好的方法吗?

#Persistent
#SingleInstance, force
ontop = 1
Gui, -Caption

Gui, Font,cPurple s10, Arial Bold
Gui, Add, Picture, x0 y0 gUImove, bg-1.jpg
Gui, Add, Picture, x0 y40, bg-1.jpg
If ontop = 1
{
    Gui, +AlwaysOnTop
}

Gui, Add, Text, x190 y0 +BackgroundTrans,test
Gui, Add, Button, x100 y200 w120 h40 , disableOnTop

Gui, Show, w500 h340

TrayTip , Title, test, 20
UImove: 
GuiClose:
ExitApp
disableOnTop:
{
    If ontop = 0
    {
        ontop = 1
        Reload
        Sleep 5000
        Return 
    }
    Else If ontop = 1
    {
        ontop = 1
        Reload
        Sleep 5000
        Return
    }
}
Return

1 个答案:

答案 0 :(得分:0)

如果要在单击GUI按钮时运行disableOnTop标签后面的代码,则需要将其名称放在按钮的选项中,并在字母“ g”之后,如下所示:

Gui, Add, Button, x100 y200 w120 h40 gdisableOnTop , Click me

要获得适当的功能,您还需要在Return之后放置Gui, Show

请注意,重新加载时不会保存变量。另外,请注意Sleep 5000ReturnReload之后,这意味着它不会被执行。 (除非它无法重新加载,例如出现语法错误。)

我很惊讶它完全在运行您的按钮代码;看来它应该会碰到ExitApp,而您所看到的只是GUI退出前的简短闪烁。

相关问题