Jump to content

countdown


Recommended Posts

you can use this:

$count_down_time = 300 ;sec
$corected_time = $count_down_time * 1000
$timer = TimerInit()
Global $display_old

While 1
;~  == display countdown part: ===
    $display = Floor(($corected_time-TimerDiff($timer))/1000)
    if $display <> $display_old Then
        TrayTip("", $display, 10)
        $display_old = $display
    EndIf
;~  == end of display countdown part ===
    if TimerDiff($timer)>= $corected_time Then
        _Do_Something()
    EndIf
WEnd

func _Do_Something()
    MsgBox(0, "OK", "countdown ended")
    Exit
EndFunc

if you don't wanna show countdown display, then delete "countdown display part"

Link to comment
Share on other sites

you can use this:

$count_down_time = 300 ;sec
$corected_time = $count_down_time * 1000
$timer = TimerInit()
Global $display_old

While 1
;~  == display countdown part: ===
    $display = Floor(($corected_time-TimerDiff($timer))/1000)
    if $display <> $display_old Then
        TrayTip("", $display, 10)
        $display_old = $display
    EndIf
;~  == end of display countdown part ===
    if TimerDiff($timer)>= $corected_time Then
        _Do_Something()
    EndIf
WEnd

func _Do_Something()
    MsgBox(0, "OK", "countdown ended")
    Exit
EndFunc

if you don't wanna show countdown display, then delete "countdown display part"

i want to use it in my gui how do i need to do that ?
Link to comment
Share on other sites

I dunno if I dunno how does your gui looks like, can you post some code of your gui?

func inbox()

$display=301

GUIDelete()

GUICreate ( "My GUI delete control", 600,200,250,200)

GUICtrlCreateLabel ("Your Logged in as: " & $USER , 5, 5, 200)

GUICtrlCreateLabel ("Your Logged in as: " & $display , 20, 20, 200)

$Button_1 = GUICtrlCreateButton ("Quit", 520, 5, 75)

$Button_2 = GUICtrlCreateButton ("Disconnect.", 440, 5, 75)

GUISetState (); Run the GUI until the dialog is closed

$msg=0

While $msg <> $GUI_EVENT_CLOSE

;~ == display countdown part: ===

$display = Floor(($corected_time-TimerDiff($timer))/1000)

if $display <> $display_old Then

; MsgBox(4096, "Test", $display)

$display_old = $display

EndIf

;~ == end of display countdown part ===

if TimerDiff($timer)>= $corected_time Then

_Do_Something()

EndIf

$msg = GUIGetMsg()

Select

Case $msg = $Button_1

quit()

Case $msg = $Button_2

disconnect()

EndSelect

WEnd

Link to comment
Share on other sites

func inbox()

$display=301

GUIDelete()

GUICreate ( "My GUI delete control", 600,200,250,200)

GUICtrlCreateLabel ("Your Logged in as: " & $USER , 5, 5, 200)

GUICtrlCreateLabel ("Your Logged in as: " & $display , 20, 20, 200)

$Button_1 = GUICtrlCreateButton ("Quit", 520, 5, 75)

$Button_2 = GUICtrlCreateButton ("Disconnect.", 440, 5, 75)

GUISetState (); Run the GUI until the dialog is closed

$msg=0

While $msg <> $GUI_EVENT_CLOSE

;~ == display countdown part: ===

$display = Floor(($corected_time-TimerDiff($timer))/1000)

if $display <> $display_old Then

; MsgBox(4096, "Test", $display)

$display_old = $display

EndIf

;~ == end of display countdown part ===

if TimerDiff($timer)>= $corected_time Then

_Do_Something()

EndIf

$msg = GUIGetMsg()

Select

Case $msg = $Button_1

quit()

Case $msg = $Button_2

disconnect()

EndSelect

WEnd

how i can reset the timer back to 300 ?

Link to comment
Share on other sites

#include <GUIConstantsex.au3>
inbox()
func inbox()
    $display = 301
    $USER = 'snd'
    $display = '301'
    $time = 300 ;sec
    $corected_time = $time * 1000
    $inbox = GUICreate ( "My GUI delete control", 600,200,250,200)
    GUICtrlCreateLabel ("Your Logged in as: " & $USER , 5, 5, 200)
    GUICtrlCreateLabel ("Your Logged in as: " & $display , 20, 20, 200)
    $Button_1 = GUICtrlCreateButton ("Quit", 520, 5, 75)
    $Button_2 = GUICtrlCreateButton ("Disconnect.", 440, 5, 75)
    GUISetState (@SW_SHOW, $inbox)
    $timer = TimerInit()

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        if TimerDiff($timer)>= $corected_time Then
            MsgBox(0, "OK", "countdown ended")
            quit()
        EndIf
        $msg = GUIGetMsg()
        switch $msg
            Case $Button_1
                quit()
            Case $Button_2
                disconnect()
        EndSwitch
    WEnd
EndFunc

func quit()
    Exit
EndFunc

func disconnect()
EndFuncoÝ÷ Ú2¢ç·¬zÛbêÛÊ)éºÛb(f§u«­¢+ØÀÌØíÑ¥µÈôQ¥µÉ%¹¥Ð ¤

Edited by sandin
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...