Autohotkey 按钮自动激活

Autohotkey 按钮自动激活,autohotkey,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.jp

我不太清楚为什么,但每当我运行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

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

Gui,添加,按钮,x100 y200 w120 h40顶部,单击我

为了获得正确的功能,您还需要在
Gui、Show
之后放置一个
Return

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

我很惊讶它竟然运行了你的按钮代码;它看起来应该运行到
ExitApp
中,您所看到的只是GUI在退出之前的一个短暂的闪烁