Jump to content

Recommended Posts

Posted (edited)

Thanks, i got that, but can someone help me here, i don't get what variable is not being declared?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$Label1 = GUICtrlCreateLabel("Welcome to this timing program. Procede with caution ", 64, 32, 460, 28)
GUICtrlSetFont(-1, 14, 400, 2, "MS Sans Serif")
$Time = GUICtrlCreateInput("Time", 232, 96, 209, 21)
$Radio1 = GUICtrlCreateRadio("Seconds", 144, 160, 113, 17)
$Radio2 = GUICtrlCreateRadio("Munites", 144, 184, 113, 17)
$Radio3 = GUICtrlCreateRadio("Hours", 144, 208, 113, 17)
$Radio4 = GUICtrlCreateRadio("Miliseconds (1000 of these = 1 second)", 144, 136, 209, 17)
$Button1 = GUICtrlCreateButton("Enable", 152, 280, 377, 145)
GUICtrlSetFont(-1, 72, 800, 4, "Segoe Script")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $Words = ""
While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $Button1 Then
        If $nMsg = $Radio4 Then
        $Timee = GUICtrlRead($Time)
        $Words = "miliseconds"
    EndIf
    If $nMsg = $Radio1 Then
        $Timee = GUICtrlRead($Time)*1000
        $Words = "seconds"
    EndIf
    If $nMsg = $Radio2 Then
        $Timee = (GUICtrlRead($Time)*1000)*60
        $Words = "minutes"
    EndIf
    If $nMsg = $Radio3 Then
        $Timee = ((GUICtrlRead($Time)*1000)*60)*60
        $Words = "hours"
    EndIf
        MsgBox(1, "Timer start", "You pressed the start button. The timer will run for "&GUICtrlRead($Time)&" "&$Words&", in miliseconds, thats "&$Timee&"." )
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Thanks >_<

By the way, without the ", in miliseconds, thats "&$Timee&"." it works just fine.

Actually, it'll only run like this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$Label1 = GUICtrlCreateLabel("Welcome to this timing program. Procede with caution ", 64, 32, 460, 28)
GUICtrlSetFont(-1, 14, 400, 2, "MS Sans Serif")
$Time = GUICtrlCreateInput("Time", 232, 96, 209, 21)
$Radio1 = GUICtrlCreateRadio("Seconds", 144, 160, 113, 17)
$Radio2 = GUICtrlCreateRadio("Munites", 144, 184, 113, 17)
$Radio3 = GUICtrlCreateRadio("Hours", 144, 208, 113, 17)
$Radio4 = GUICtrlCreateRadio("Miliseconds (1000 of these = 1 second)", 144, 136, 209, 17)
$Button1 = GUICtrlCreateButton("Enable", 152, 280, 377, 145)
GUICtrlSetFont(-1, 72, 800, 4, "Segoe Script")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Words = ""
While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $Radio4 Then
        $Timee = GUICtrlRead($Time)
        $Words = "miliseconds"
    EndIf
    If $nMsg = $Radio1 Then
        $Timee = GUICtrlRead($Time)*1000
        $Words = "seconds"
    EndIf
    If $nMsg = $Radio2 Then
        $Timee = (GUICtrlRead($Time)*1000)*60
        $Words = "minutes"
    EndIf
    If $nMsg = $Radio3 Then
        $Timee = ((GUICtrlRead($Time)*1000)*60)*60
        $Words = "hours"
    EndIf
    If $nMsg = $Button1 Then
        MsgBox(1, "Timer start", "You pressed the start button. The timer will run for "&GUICtrlRead($Time)&" "&$Words&"." )
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by AutoitFaN1000
Posted

Stuff isn't declared global. So when it exits the local scope, the variable goes 'poof'.

Here you go. Rewrite...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;
Global $Words, $Timee


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$Label1 = GUICtrlCreateLabel("Welcome to this timing program. Procede with caution ", 64, 32, 460, 28)
GUICtrlSetFont(-1, 14, 400, 2, "MS Sans Serif")
$Time = GUICtrlCreateInput("1000", 232, 96, 209, 21, 0x2000) ; 0x2000 = ES_NUMBER
$Radio1 = GUICtrlCreateRadio("Seconds", 144, 160, 113, 17)
$Radio2 = GUICtrlCreateRadio("Minutes", 144, 184, 113, 17)
$Radio3 = GUICtrlCreateRadio("Hours", 144, 208, 113, 17)
$Radio4 = GUICtrlCreateRadio("Miliseconds (1000 of these = 1 second)", 144, 136, 209, 17)
$Button1 = GUICtrlCreateButton("Enable", 152, 280, 377, 145)
GUICtrlSetFont(-1, 72, 800, 4, "Segoe Script")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $Words = ""
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If GUICtrlRead($Radio4) = $GUI_CHECKED Then
                $Timee = GUICtrlRead($Time)
                $Words = "miliseconds"
                MsgBox(1, "Timer start", "You pressed the start button. The timer will run for " & GUICtrlRead($Time) & " " & $Words & ", in miliseconds, thats " & $Timee & "." )
            ElseIf GUICtrlRead($Radio1) = $GUI_CHECKED Then
                $Timee = GUICtrlRead($Time)*1000
                $Words = "seconds"
                MsgBox(1, "Timer start", "You pressed the start button. The timer will run for " & GUICtrlRead($Time) & " " & $Words & ", in miliseconds, thats " & $Timee & "." )
            ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
                $Timee = (GUICtrlRead($Time)*1000)*60
                $Words = "minutes"
                MsgBox(1, "Timer start", "You pressed the start button. The timer will run for " & GUICtrlRead($Time) & " " & $Words & ", in miliseconds, thats " & $Timee & "." )
            ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
                $Timee = (GUICtrlRead($Time)*1000)*3600
                $Words = "hours"
                MsgBox(1, "Timer start", "You pressed the start button. The timer will run for " & GUICtrlRead($Time) & " " & $Words & ", in miliseconds, thats " & $Timee & "." )
            EndIf
    EndSwitch
WEnd
Posted (edited)

Thanks, but how could i intergrate this

Sleep( $Timee )
MsgBox(0, "Times up!", "Your time is up!!")

into the code you so kindly rewrote for me. It seems that you are runing the messagebox when they hit Radio3, so i dont know where to put the sleep part...

Edited by AutoitFaN1000

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
×
×
  • Create New...