mati

countdown GUI in background

3 posts in this topic

#1 ·  Posted

Hi,

I wish to create a GUI that shows a countdown but stays in the background as infobox while other tasks continue. So far I have with use of other snippets from the forum created a countdown but the GUI seems block the script from continuing. How can I 'deactivate' the GUI but keep the countdown running? The GUI box should close at the end of the main script (or after countdown end).

 

Thanks for help,

mati

 

#include <GUIConstants.au3>
#include <Date.au3>


$sNewDate = _DateAdd('n', 1, _NowCalc())


$ms = 61000 ;(1 min)
$timer = TimerInit()
$labeltext1 = "This run will be finished in"

$labeltext2 = "minutes at: " & _DateTimeFormat($sNewDate, 3)

;


$GUI = GUICreate("Next start", 170, 170, 150,150, $WS_DLGFRAME, $WS_EX_TOPMOST)
$Install = GUICtrlCreateButton ("Ok", 50, 95, 50, 50, $BS_DEFPUSHBUTTON)
$Label1 = GUICtrlCreateLabel($labeltext1, 10, 10, 330, 200)
$Label2 = GUICtrlCreateLabel($labeltext2, 25, 80, 330, 200)
$Input = GUICtrlCreateInput("", 50, 40, 35, 20, BitOR($SS_CENTER, $ES_READONLY))
$aWin = WinGetPos($GUI)

GUISetState(@SW_SHOWNOACTIVATE)

While (TimerDiff($timer) < $ms) and (GUIGetMsg() <> $Install)

    ;
    $seconds = TimerDiff($timer) / 1000
    $diff = $seconds - ($ms / 1000)
    ;
    $minutes = Int($diff / 60)
    $secondsRem = $diff - ($minutes * 60)
    ;
    $minutes = $minutes * -1
    $secondsRem = $secondsRem * -1
    $time = StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
    ;
    GUICtrlSetData($Input, $time)
    ;
WEnd


; just for test purpose
WinActivate("AutoIt Help (v3.3.14.2)")
WinWaitActive("AutoIt Help (v3.3.14.2)")
WinClose("AutoIt Help (v3.3.14.2)")

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @mati:)

What are you trying to do?

And please, use the Code tag to make a good reading of your post, thanks :)

 

Best regards.


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi FrancescoDiMuro,

 

Sorry for the code thing - rookie mistake.

What I try to do:

I have two processes I control with AutoIt. Process 1 is variable in time, directly followed by process 2  which is consistent in duration.

After starting the script, I never know, when the entire script will be finished. So I thought, it would be helpful to implement a function between the two processes, which starts a countdown (or shows an expected finishing time). However, if I use a msgbox or GUI, I have to destroy the box to continue the script (process 2). Is there a possibility to 'inactivate' a GUI window (message box) so that the scrip can continue but the countdown/expected finishing time is still displayed on the screen?

 

Thanks a lot for help,

mati

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now