Sign in to follow this  
Followers 0
mentosan

is this possible ?

13 posts in this topic

Hi !

I want to add a countdown timer to the MsgBox(). Is this possible ?

Thank you.

Share this post


Link to post
Share on other sites



The MSGBOX is static as far as i know. Alternative would be to build a form just like a MSGBOX.

Share this post


Link to post
Share on other sites

@notsure: Thanks for the tip ^_^ A tough one....

Share this post


Link to post
Share on other sites

The MSGBOX has a built in countdown timer functionality. It is just not visible .If you need it visible you will have to create a GUI

Share this post


Link to post
Share on other sites

I want it visible.

Share this post


Link to post
Share on other sites

Hi !

I want to add a countdown timer to the MsgBox(). Is this possible ?

Thank you.

@mentosan

search for 'MsgBox countdown'

your choice if you want to mod MsgBox() or roll your own with Guicreate()

AdlibEnable/setTimer method - MsgBox with countdown on buttons and/or title

includes example and more links other msgbox authors scripts

How to add this type of countdown w/o new boxes?, So no flicker and dimming ...

xMsgBox - ProgAndy

xMsgBox - ProgAndy

an modified example of ProgAndy's msgbox with SetWindowsHookEx

Add a drop shadow to native AutoIt GUI Forms and Dialogs, Minimum OS Windows XP

another one by CyberSlug

MsgBox with countdown (GUI)


I see fascists...

Share this post


Link to post
Share on other sites

I have found this code here on the forum and I would like to use it in my script.

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>
#include <Date.au3>
#include <ProgressConstants.au3>

Global $iCountdown = 6; Sets the time-out in seconds

$iTotal_Time = 5
$Prompt = 0

$Form1 = GUICreate("Remaining Time To Continue", 415, 145, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_WINDOWEDGE); Creates GUI Window
$Progress = GUICtrlCreateProgress(10, 65, 395, 15, $PBS_SMOOTH); Creates Progress Bar
GUICtrlSetColor($Progress, 0xff0000); Sets Progress Bar Color
$Label1 = GUICtrlCreateLabel("", 10, 10, 405, 25)
GUISetState(@SW_SHOW)

_Timer_SetTimer($Form1, 1000, '_Countdown')

While 1
    $nMsg = GUIGetMsg()
WEnd

;-------------Functions Below this Line---------------------------

Func _Countdown($hWnd, $iMsg, $iIDTimer, $dwTime)
    $iCountdown -= 1
    $percent_value = (($iCountdown / $iTotal_Time) * 100)
    If $iCountdown > 0 Then
        GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue")
        GUICtrlSetData($Progress, $percent_value)
    ElseIf $percent_value <= 0 Then
        GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue")
        GUICtrlSetData($Progress, $percent_value)
        Exit
    EndIf
EndFunc;==>_Countdown

Func _SecsToTime($iSecs)
    Local $iHours, $iMins, $iSec_s
    _TicksToTime($iSecs*1000,$iHours,$iMins,$iSec_s)
    Return StringFormat("%01i:%02i",$iMins, $iSec_s)
EndFunc

I have not succeded to call it from my script. I do not want to mess it up with my script, i just wanna use in my script #include<name_of_above_code.au3> and then somehow to call it. Thank you in advance for your support !

Share this post


Link to post
Share on other sites

So ? Make it a Function and call it whenever you want with the function name...

Share this post


Link to post
Share on other sites

#10 ·  Posted

Can you detail how to create a function if it's an external file ?

Share this post


Link to post
Share on other sites

#11 ·  Posted

Copy bellow to your script

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>
#include <Date.au3>
#include <ProgressConstants.au3>

Global $iCountdown = 6; Sets the time-out in seconds

;Call the function
Whatever()


Func Whatever()

$iTotal_Time = 5

$Prompt = 0

$Form1 = GUICreate("Remaining Time To Continue", 415, 145, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_WINDOWEDGE); Creates GUI Window
$Progress = GUICtrlCreateProgress(10, 65, 395, 15, $PBS_SMOOTH); Creates Progress Bar
GUICtrlSetColor($Progress, 0xff0000); Sets Progress Bar Color
$Label1 = GUICtrlCreateLabel("", 10, 10, 405, 25)
GUISetState(@SW_SHOW)

_Timer_SetTimer($Form1, 1000, '_Countdown')

While 1
    $nMsg = GUIGetMsg()
WEnd
End func
;-------------Functions Below this Line---------------------------

Func _Countdown($hWnd, $iMsg, $iIDTimer, $dwTime)
    $iCountdown -= 1
    $percent_value = (($iCountdown / $iTotal_Time) * 100)
    If $iCountdown > 0 Then
        GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue")
        GUICtrlSetData($Progress, $percent_value)
    ElseIf $percent_value <= 0 Then
        GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue")
        GUICtrlSetData($Progress, $percent_value)
        Exit
    EndIf
EndFunc;==>_Countdown

Func _SecsToTime($iSecs)
    Local $iHours, $iMins, $iSec_s
    _TicksToTime($iSecs*1000,$iHours,$iMins,$iSec_s)
    Return StringFormat("%01i:%02i",$iMins, $iSec_s)
EndFunc

Share this post


Link to post
Share on other sites

#12 ·  Posted

AAh, I see now. You did opposite as I expected. You have included in this code my script. I was thinking viceversa to include in my script this code. Thanks anyway!

Share this post


Link to post
Share on other sites

#13 ·  Posted

I didnt get what you want exactly but lets say you have the code compiled to an .exe file.

Whenever you want to include it/call it in your code just use :

RunWait("C:\Exefile.exe)

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
Sign in to follow this  
Followers 0