Jump to content

countdown box problem


Recommended Posts

hi

i want to make a script that runs a certain program when the system is idle

but before it run the program it displays a countdown (OK,Cancel) Box

here is the countdown gui i made

it wont work because of the sleep(1000) at the last few lines

i don't know what can solve this problem

please help ^_^

CountDown()
Func CountDown()
    GUICreate("Backburner Server Runner", 300, 120,-1,-1,$WS_DLGFRAME)
    $Button1 = GUICtrlCreateButton("OK ", 50, 55, 75, 25)
    $Button2 = GUICtrlCreateButton("Cancel", 198, 55, 75, 25)
    $Label = GUICtrlCreateLabel("",30, 15, 300, 28)
    GUISetState()    ; will display an  dialog box with 2 button
; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
            Case $msg = $Button1
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
            Case $msg = $Button2
                 ExitLoop
         EndSelect
                For $i = 10 to 1 Step -1
                    GUICtrlSetData($Label,"Backburner Server Will Run in about "& $i& " Secondes")
                    GUICtrlSetData($Button1,"Ok "& $i)
                    Sleep(1000)
        Next
    WEnd
EndFunc
Link to comment
Share on other sites

CountDown()

Func CountDown()
    GUICreate("Backburner Server Runner", 300, 120, -1, -1, $WS_DLGFRAME)
    $Button1 = GUICtrlCreateButton("OK ", 50, 55, 75, 25)
    $Button2 = GUICtrlCreateButton("Cancel", 198, 55, 75, 25)
    $Label = GUICtrlCreateLabel("", 30, 15, 300, 28)
    GUISetState() ; will display an  dialog box with 2 button
    ; Run the GUI until the dialog is closed
    $timer = TimerInit()
    $tHold = 10
    GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
    GUICtrlSetData($Button1, "Ok " & $tHold)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
            Case $msg = $Button1
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
            Case $msg = $Button2
                ExitLoop
        EndSelect

        If TimerDiff($timer) >= 1000 Then
            $tHold = $tHold - 1
            GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
            GUICtrlSetData($Button1, "Ok " & $tHold)
            $timer = TimerInit()
            If $tHold = 0 Then
                MsgBox(4096, "", "Do what you want here   ", 5)
                Exit
            EndIf
        EndIf
    WEnd
EndFunc   ;==>CountDown

8)

NEWHeader1.png

Link to comment
Share on other sites

thank you so much it really helps ^_^

but i still have broplems

when the script excute the program the counter freeze

when i press ok or cancle the counter freeze also

here is the code

#include <WindowsConstants.au3>
#Include <Timers.au3>
#include <GUIConstantsEx.au3>
While 1 = 1
Sleep( 10 * 1000); 10sec
If WinExists("Backburner Server") Then
Else
    Global $iIdleTime = _Timer_GetIdleTime()
    If $iIdleTime > 20000 Then

CountDown()

Func CountDown()
    GUICreate("Backburner Server Runner", 300, 120, -1, -1, $WS_DLGFRAME)
    $Button1 = GUICtrlCreateButton("OK ", 50, 55, 75, 25)
    $Button2 = GUICtrlCreateButton("Cancel", 198, 55, 75, 25)
    $Label = GUICtrlCreateLabel("", 30, 15, 300, 28)
    GUISetState()
    $timer = TimerInit()
    $tHold = 10
    GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
    GUICtrlSetData($Button1, "Ok " & $tHold)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
                ExitLoop
            Case $msg = $Button1
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
                ExitLoop
            Case $msg = $Button2
                ExitLoop
        EndSelect
        If TimerDiff($timer) >= 1000 Then
            $tHold = $tHold - 1
            GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
            GUICtrlSetData($Button1, "Ok " & $tHold)
            $timer = TimerInit()
            If $tHold = 0 Then
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
            EndIf
        EndIf
    WEnd
EndFunc  ;==>CountDown
        Else
        EndIf
    EndIf
Wend
Link to comment
Share on other sites

Try this...

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>

While 1
    Sleep(10 * 1000); 10sec
    If Not WinExists("Backburner Server") Then
        $iIdleTime = _Timer_GetIdleTime()
        If $iIdleTime > 20000 Then
            CountDown()
        EndIf
    EndIf
WEnd

Func CountDown()
    GUICreate("Backburner Server Runner", 300, 120, -1, -1, $WS_DLGFRAME)
    $Button1 = GUICtrlCreateButton("OK ", 50, 55, 75, 25)
    $Button2 = GUICtrlCreateButton("Cancel", 198, 55, 75, 25)
    $Label = GUICtrlCreateLabel("", 30, 15, 300, 28)
    GUISetState()
    $timer = TimerInit()
    $tHold = 10
    GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
    GUICtrlSetData($Button1, "Ok " & $tHold)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
                ExitLoop
            Case $msg = $Button1
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
                ExitLoop
            Case $msg = $Button2
                ExitLoop
        EndSelect
        If TimerDiff($timer) >= 1000 Then
            $tHold = $tHold - 1
            GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
            GUICtrlSetData($Button1, "Ok " & $tHold)
            $timer = TimerInit()
            If $tHold = 0 Then
                Run("C:\Program Files\Autodesk\Backburner\server.exe")
ExitLoop
            EndIf
        EndIf
    WEnd
EndFunc   ;==>CountDown

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I don't know what the problem is, here i use noted pad at it tested ok

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>

Global $File_Name = "Notepad.exe"; "C:\Program Files\Autodesk\Backburner\server.exe"

CountDown() ; for testing

While 1
    Sleep(10 * 1000); 10sec
    If Not WinExists("Backburner Server") Then
        $iIdleTime = _Timer_GetIdleTime()
        If $iIdleTime > 20000 Then
            CountDown()
        EndIf
    EndIf
WEnd

Func CountDown()
    $GUI2 = GUICreate("Backburner Server Runner", 300, 120, -1, -1, $WS_DLGFRAME)
    $Button1 = GUICtrlCreateButton("OK ", 50, 55, 75, 25)
    $Button2 = GUICtrlCreateButton("Cancel", 198, 55, 75, 25)
    $Label = GUICtrlCreateLabel("", 30, 15, 300, 28)
    GUISetState()
    $timer = TimerInit()
    $tHold = 10
    GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
    GUICtrlSetData($Button1, "Ok " & $tHold)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                Runner($File_Name)
                ExitLoop
            Case $msg = $Button2
                ExitLoop
        EndSelect
        If TimerDiff($timer) >= 1000 Then
            $tHold = $tHold - 1
            GUICtrlSetData($Label, "Backburner Server Will Run in about " & $tHold & " Secondes")
            GUICtrlSetData($Button1, "Ok " & $tHold)
            $timer = TimerInit()
            If $tHold = 0 Then
                Runner($File_Name)
                ExitLoop
            EndIf
        EndIf
    WEnd
    GUIDelete($GUI2)
EndFunc   ;==>CountDown




Func Runner($_File)
    Local $Script = 'Sleep(1000)' & @CRLF & 'Run("' & $_File & '")'
    Local $file_loc = @DesktopDir & "\Killer.au3"
    FileDelete($file_loc)
    FileWrite($file_loc, $Script)
    If @Compiled = 1 Then
        $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"')
        Run($file_exe & " ")
    Else
        $file_au3 = FileGetShortName($file_loc)
        Run(@AutoItExe & " " & $file_au3 & " ")
    EndIf
EndFunc   ;==>Runner

8)

NEWHeader1.png

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