Hello everywhere, I have the following subroutine
-------------------------------------------------------------------------
DoWhenTimeout(Reason, FnctNr) ; führt die Funktion aus, wenn nicht unterbrochen wird
global MyProgress
GUI, add, text,,%Reason% (Timeout = 10s) abbrechen?
GUI, add, Progress, w200 h20 cBlue VMyProgress Range0-1000
GUI, add, Button, Default, &Abbrechen
GUI, show, Restore, %Reason%
Loop, 1000 ; führt den folgenden Block 1000 mal aus
{
sleep, 10 ; also 10 ms-> Dauer =...
GuiControl,, MyProgress, +1
}
GUI, Destroy
{
; Shutdown, FnctNr ; 1 = ShutDown, 2 = reboot
msgbox , jetzt hätte shutdown/reboot stattgefunden
}
GUIEscape:
GUIClose:
ButtonAbbrechen:
IsTimeout = 0
msgbox , Success: Abgebrochen
GUI, Destroy
return
--------------------------------------------------------------------------------------------------------------
but even if I abort the GUI, it will always reboot (type the reboot comas)
What die I wrong?
Thank you very much in advance
MunichFan
Why is the GUI not aborted
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: Why is the GUI not aborted
throughout your whole code I only see 1 "Return" statement, so your code is going through the whole code until it hits that return. So I'm not sure exactly where you want to auto-execute to stop, but I think this is just a problem of code running that should not be ran yet.
Re: Why is the GUI not aborted
Indeed, it looks like there may be a number of issues. Along with what Manny mentioned, is this all part of the DoWhenTimeout function? Or are you calling it and it's somewhere else in your code not shown?
Re: Why is the GUI not aborted, solution
Hello MannyKSoSo, hello eelrod
thank you very much for your help. With that help and hint I found at least one solution for me
- You are right MannyKSoSo, I have to add return before GuiEscape
- @eelrod: Yes I should mention the calling part
Now it looks like this:
---------------------------------------------------------------------------------------------------------
!^s::DoWhenTimeout("ShutDown",1)
!^r::DoWhenTimeout("Reboot", 2)
...
DoWhenTimeout(Reason, FnctNr)
{
global MyProgress
GUI, add, text,,%Reason% (Timeout = 10s) abbrechen?
GUI, add, Progress, w200 h20 cBlue VMyProgress Range0-1000
GUI, add, Button, Default, Abbrechen
GUI, show, Restore, %Reason%
Loop, 1000 ; that means for 10s
{
sleep, 10
GuiControl,, MyProgress, +1
}
GUI, Destroy
if (FnctNr = 1) or (FnctNr = 2)
{
Shutdown, FnctNr ; 1 = ShutDown, 2 = reboot
}
return
GuiEscape:
GuiClose:
ButtonAbbrechen:
FnctNr = 0 ; if I leave that it makes shutdown after 10 seconds in any case
GUI, Destroy
return
}
---------------------------------------------------------------------------------------------------------
It seems that the reset of FnctNr=0 is essential, elsewhere it goes back to the ShutDown-Command
I don't understand why
But still thank you very much for your prefessional help
thank you very much for your help. With that help and hint I found at least one solution for me
- You are right MannyKSoSo, I have to add return before GuiEscape
- @eelrod: Yes I should mention the calling part
Now it looks like this:
---------------------------------------------------------------------------------------------------------
!^s::DoWhenTimeout("ShutDown",1)
!^r::DoWhenTimeout("Reboot", 2)
...
DoWhenTimeout(Reason, FnctNr)
{
global MyProgress
GUI, add, text,,%Reason% (Timeout = 10s) abbrechen?
GUI, add, Progress, w200 h20 cBlue VMyProgress Range0-1000
GUI, add, Button, Default, Abbrechen
GUI, show, Restore, %Reason%
Loop, 1000 ; that means for 10s
{
sleep, 10
GuiControl,, MyProgress, +1
}
GUI, Destroy
if (FnctNr = 1) or (FnctNr = 2)
{
Shutdown, FnctNr ; 1 = ShutDown, 2 = reboot
}
return
GuiEscape:
GuiClose:
ButtonAbbrechen:
FnctNr = 0 ; if I leave that it makes shutdown after 10 seconds in any case
GUI, Destroy
return
}
---------------------------------------------------------------------------------------------------------
It seems that the reset of FnctNr=0 is essential, elsewhere it goes back to the ShutDown-Command
I don't understand why
But still thank you very much for your prefessional help
Who is online
Users browsing this forum: AlFlo, VaritySpice and 117 guests