Jump to content

is this possible ?


Recommended Posts

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...

Link to comment
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 !

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...