Sign in to follow this  
Followers 0
Bert

Asking for I not sure what to ask for...

16 posts in this topic

I've spent some time researching on how to do this, but I don't know what to use as a search, so I will try to describe what I need to do.

I designed a timer that just has a start and stop. I need to do the following:

-every hour on the hour while it is running, a msgbox pops up with a reminder.

I'm not sure on how to make it know how each hour goes by and keep a count while doing it.

here is the code:

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Timer1Active = 0
Dim $Timer2Active = 0
AdlibEnable("AllTimers1", 500)

GUICreate("MyGUI", 120, 120)

$Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20)
$Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001)
GUICtrlSetBkColor($Label_4, 0xFF0000)
GUICtrlSetFont($Label_4, 16)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
            GUICtrlSetBkColor($Label_4, 0x64C671)
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
            GUICtrlSetBkColor($Label_4, 0xFF0000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers1()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
       
    EndIf
EndFunc ;==>AllTimers

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Dim $Timer = TimerInit()

While 1
    If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then
        MsgBox(0, "Time", "Hour is up")
        $Timer = TimerInit()
    EndIf
WEnd

Edit:

I re-read your post, are you meaning the 'literal hour' - 12pm / 1pm / 2pm etc....?

Edit2:

If it is the above, maybe try something like:

While 1
    If $Hour - @HOUR = 0 And $Min - @MIN = 0 And $Sec - @Sec <= 10 Then
        Sleep($Sec - @SEC * 1000)
    ; do something and reset timer
    EndIf
WEnd
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well either example does that vollyman.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

MsgBox(0, "Time", "Hour is up",10)

make shure the box closes after a while otherwise the program will wait for user input (clicking ok button)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I've spent some time researching on how to do this, but I don't know what to use as a search, so I will try to describe what I need to do.

I designed a timer that just has a start and stop. I need to do the following:

-every hour on the hour while it is running, a msgbox pops up with a reminder.

I'm not sure on how to make it know how each hour goes by and keep a count while doing it.

here is the code:

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Timer1Active = 0
Dim $Timer2Active = 0
AdlibEnable("AllTimers1", 500)

GUICreate("MyGUI", 120, 120)

$Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20)
$Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001)
GUICtrlSetBkColor($Label_4, 0xFF0000)
GUICtrlSetFont($Label_4, 16)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
            GUICtrlSetBkColor($Label_4, 0x64C671)
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
            GUICtrlSetBkColor($Label_4, 0xFF0000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers1()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
       
    EndIf
EndFunc;==>AllTimers
probably the easiest way to do it, in my opinion, would be to create a variable that stores the old label text, then when the timer label is updated, compare the hour position. if it changes, display a message box. then you have your count, and your hourly message box.

***forgot english for a minute, fixed gramatical errors... screw capitalization.***

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

probably the easiest way to do it, in my opinion, would be to create a variable that stores the old label text, then when the timer label is updated, compare the hour position. if it changes, display a message box. then you have your count, and your hourly message box.

***forgot english for a minute, fixed gramatical errors... screw capitalization.***

Well I had never seen the _TicksToTime() UDF before this post (never paid much attention), and after about 20 seconds of reading it, It made perfect sense... In either case as you say, keeping the label updated is important if the program is going to run past the given hour.

@Spacely - Yeh, I didn't put that in there as something to stay, I thought he would replace it with the code he wanted, I think it was a ControlSetText() command. I just didn't write it to fit his specific function, I thought he could at least do that with either example given to him.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Well either example does that vollyman.

I ran a 2 hour test, and the message only poped up on hour 1.

$Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001)
GUICtrlSetBkColor($Label_4, 0xFF0000)
GUICtrlSetFont($Label_4, 16)
Dim $Timer = TimerInit()
GUISetState()

While 1
    $msg = GUIGetMsg()  
        If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then
        MsgBox(0, "Reminder", "Check Voice", 10)
        $Timer = TimerInit()
        EndIf
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
            GUICtrlSetBkColor($Label_4, 0x64C671)
           ;If TimerDiff($Timer) / 1000 / 60 / 60 >= 1 Then
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
            GUICtrlSetBkColor($Label_4, 0xFF0000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers1()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
       
    EndIf
EndFunc ;==>AllTimers
Edited by vollyman

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

maybe

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Timer1Active = 0
Dim $Timer2Active = 0
AdlibEnable("AllTimers1", 500)

Dim $count = "01"

GUICreate("MyGUI", 120, 120)

$Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20)
$Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001)
GUICtrlSetBkColor($Label_4, 0xFF0000)
GUICtrlSetFont($Label_4, 16)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
            GUICtrlSetBkColor($Label_4, 0x64C671)
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
            GUICtrlSetBkColor($Label_4, 0xFF0000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers1()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
      
    EndIf
    If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then
        MsgBox(64, " Hour Message", " One Hour has Passed   ", 10)
        $count = $count + "01"
        If $count < 10 then $count = "0" & $count
    EndIf
EndFunc;==>AllTimers

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

yepper... 8)

you could add this

If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then
        If $count = "01" Then 
            MsgBox(64, " Hour Message", " One Hour has Passed   ", 10)
        Else
            MsgBox(64, " Hour Message", $count & " Hours have Passed   ", 10)
                EndIf
        $count = $count + "01"
        If $count < 10 then $count = "0" & $count
    EndIf

this will give a "count" of how many hours have passed

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

The message the client needed, believe it or not, is simply check the voice system they use for tickets. It has to be monitored by one person on the help desk, and the person changes from day to day. They asked me to write something that could be like a alarm clock that only did a popup every hour. I was going to put the code into a app I'm designing for them so it would be all in one program.

Still, it is good code. Thank you! :P

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Voice... did you say Voice...

#include <GUIConstants.au3>
#include <Date.au3>

Dim $Timer1Active = 0
Dim $Timer2Active = 0
AdlibEnable("AllTimers1", 500)

Dim $count = "01"

GUICreate("MyGUI", 120, 120)

$Button_1 = GUICtrlCreateButton("Start", 10, 50, 50, 20)
$Button_2 = GUICtrlCreateButton("Stop", 60, 50, 50, 20)
$Label_4 = GUICtrlCreateLabel("00:00:00", 10, 10, 100, 30, 0x00800000 + 0x0001)
GUICtrlSetBkColor($Label_4, 0xFF0000)
GUICtrlSetFont($Label_4, 16)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button_1
            $Timer1Active = 1
            $timer1 = TimerInit()
            GUICtrlSetBkColor($Label_4, 0x64C671)
        Case $msg = $Button_2
            $Timer1Active = 0
            GUICtrlSetData($Label_4, "00:00:00")
            GUICtrlSetBkColor($Label_4, 0xFF0000)
        Case $msg = $GUI_EVENT_CLOSE
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func AllTimers1()
    Local $Secs, $Mins, $Hour, $Time1, $Time2, $sTime1 = $Time1, $sTime2 = $Time2
    Dim $read1 = "One, Hour, Past, Start"
    Dim $read2 = int($count) & ", Hours, Past, Start"  
    If $Timer1Active Then
        _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
        $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        If $sTime1 <> $Time1 Then ControlSetText("MyGUI", "", "Static1", $Time1)
      
    EndIf
    If StringLeft((GUICtrlRead($Label_4)), 2) = $count Then
        If $count = "01" Then
            _TalkOBJ($read1)
            MsgBox(64, " Hour Message", " One Hour has Passed   ", 10)
        Else
            _TalkOBJ($read2)
            MsgBox(64, " Hour Message", $count & " Hours have Passed   ", 10)
        EndIf
        $count = $count + "01"
        If $count < 10 then $count = "0" & $count
    EndIf
EndFunc;==>AllTimers

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc;==>_TalkOBJ

lol

8)

EDIT.... fixed Voice

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

okok....let me guess...this will talk to you????? I have to run it to test it, but......hehehheh <WEG> :P

yepper.... 8)

8)

EDIT.....

re-did the above post for the Voice

8)

Edited by Valuater

NEWHeader1.png

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  
Followers 0