Jump to content
Sign in to follow this  
yucatan

countdown

Recommended Posts

yucatan

hi i wanne make a countdown of 300 sec if the 300 sec are over i wane that a func is runned b.v the script give a msgbox and then exits is this posseble ?

Share this post


Link to post
Share on other sites
sandin

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"

Share this post


Link to post
Share on other sites
yucatan

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 ?

Share this post


Link to post
Share on other sites
sandin
yucatan

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

Share this post


Link to post
Share on other sites
yucatan

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 ?

Share this post


Link to post
Share on other sites
sandin

#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

Share this post


Link to post
Share on other sites
yucatan

how i can reset the timer back to 300 ?

if have a $var containing a word how do i change the first letter of the word in to a capital

so not $var = yucatan

becomes

$var=Yucatan

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.