Problems in a GUI with Countdown Script
Posted: 05 Nov 2018, 16:10
Hello!
I´m learning Autohotkey Script now since maybe 5 years, and every day i learn something new.
Normally i first try all of my knowledge to make a script of my desire without asking.
But this time, i think i must ask this. This actually drived me crazy. I worked on this the whole day and i can´t get it work even if i done a similar thing before.
Okay, first, here is the script:
SetWorkingDir %A_ScriptDir%\TOOLS\Icons\
Gui, Font, s0
Gui +Border +Caption
Gui, Add, Picture, x0 y0 w1010 h590, %A_ScriptDir%\TOOLS\Icons\Background.png
Gui, Font, s13 Bold, Arial
Gui, Add, Picture, BackgroundTrans x380 y180 w250 h70, %A_ScriptDir%\TOOLS\Icons\Button.png
Gui, Add, Text, cFFFFFF BackgroundTrans x405 y205 w200 Center gButton01, YES
Gui, Add, Picture, BackgroundTrans x380 y340 w250 h70, %A_ScriptDir%\TOOLS\Icons\Button.png
Gui, Add, Text, cFFFFFF BackgroundTrans x405 y365 w200 Center gButton02, NO
Gui, +Owner
Gui, Show, ,Do You Want To Launch The Program?
Wait(5000)
Wait(time)
{
static MyProgress
tick:=A_TickCount+time
Gui, Margin,0,0
Gui, Add, Progress, x355 y280 w300 h20 cgreen -smooth Range%A_TickCount%-%tick% vMyProgress
Gui, Show, NA
While A_TickCount<=tick
{
GuiControl,,MyProgress,% A_TickCount
Sleep 16
}
Gui, Destroy
}
Return
Button01:
Gui, Destroy
Goto, PROGRAM01
Return
Button02:
Gui, Destroy
Goto, PROGRAM02
Return
GuiClose:
Gui, Destroy
I should explain what i want from this script.
This should be a GUI for a program. When you launch it, it asks if you want to launch "PROGRAM01". It gives you a timer to answer yes or no.
When pressing the button "Yes", it launches "PROGRAM01". When pressing the button "No", it won´t launch "PROGRAM01", but instead launches "PROGRAM02". When not pressing any button in the timed Countdown, it then automaticly launches still "PROGRAM01".
My problem with this?
For whatever reason, even when pressing "No", so it should launches "PROGRAM02", it still launches "PROGRAM01".
I did something similar before and now i can´t get it working anymore. I don´t get it.
I think the problem lies in the countdown timer. It won´t stop regardless i press "PROGRAM02" or close the GUI.
Thanks everyone for any help.
I´m learning Autohotkey Script now since maybe 5 years, and every day i learn something new.
Normally i first try all of my knowledge to make a script of my desire without asking.
But this time, i think i must ask this. This actually drived me crazy. I worked on this the whole day and i can´t get it work even if i done a similar thing before.
Okay, first, here is the script:
SetWorkingDir %A_ScriptDir%\TOOLS\Icons\
Gui, Font, s0
Gui +Border +Caption
Gui, Add, Picture, x0 y0 w1010 h590, %A_ScriptDir%\TOOLS\Icons\Background.png
Gui, Font, s13 Bold, Arial
Gui, Add, Picture, BackgroundTrans x380 y180 w250 h70, %A_ScriptDir%\TOOLS\Icons\Button.png
Gui, Add, Text, cFFFFFF BackgroundTrans x405 y205 w200 Center gButton01, YES
Gui, Add, Picture, BackgroundTrans x380 y340 w250 h70, %A_ScriptDir%\TOOLS\Icons\Button.png
Gui, Add, Text, cFFFFFF BackgroundTrans x405 y365 w200 Center gButton02, NO
Gui, +Owner
Gui, Show, ,Do You Want To Launch The Program?
Wait(5000)
Wait(time)
{
static MyProgress
tick:=A_TickCount+time
Gui, Margin,0,0
Gui, Add, Progress, x355 y280 w300 h20 cgreen -smooth Range%A_TickCount%-%tick% vMyProgress
Gui, Show, NA
While A_TickCount<=tick
{
GuiControl,,MyProgress,% A_TickCount
Sleep 16
}
Gui, Destroy
}
Return
Button01:
Gui, Destroy
Goto, PROGRAM01
Return
Button02:
Gui, Destroy
Goto, PROGRAM02
Return
GuiClose:
Gui, Destroy
I should explain what i want from this script.
This should be a GUI for a program. When you launch it, it asks if you want to launch "PROGRAM01". It gives you a timer to answer yes or no.
When pressing the button "Yes", it launches "PROGRAM01". When pressing the button "No", it won´t launch "PROGRAM01", but instead launches "PROGRAM02". When not pressing any button in the timed Countdown, it then automaticly launches still "PROGRAM01".
My problem with this?
For whatever reason, even when pressing "No", so it should launches "PROGRAM02", it still launches "PROGRAM01".
I did something similar before and now i can´t get it working anymore. I don´t get it.
I think the problem lies in the countdown timer. It won´t stop regardless i press "PROGRAM02" or close the GUI.
Thanks everyone for any help.