按钮自动激活
Button automatically activating
我不太清楚为什么,但是每当我 运行 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, Add, Button, x100 y200 w120 h40 gdisableOnTop , Click me
为了获得正确的功能,您还需要在 Gui, Show
之后添加 Return
。
请注意,重新加载时不会保存变量。另外,请注意 Sleep 5000
和 Return
在 Reload
之后,这意味着它不会被执行。 (除非无法重载,比如语法错误。)
令我惊讶的是,它 运行 完全是您的按钮代码;看起来它应该 运行 进入 ExitApp
并且你所看到的只是 GUI 在它退出之前的一个短暂闪现。
我不太清楚为什么,但是每当我 运行 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, Add, Button, x100 y200 w120 h40 gdisableOnTop , Click me
为了获得正确的功能,您还需要在 Gui, Show
之后添加 Return
。
请注意,重新加载时不会保存变量。另外,请注意 Sleep 5000
和 Return
在 Reload
之后,这意味着它不会被执行。 (除非无法重载,比如语法错误。)
令我惊讶的是,它 运行 完全是您的按钮代码;看起来它应该 运行 进入 ExitApp
并且你所看到的只是 GUI 在它退出之前的一个短暂闪现。