Jump to content

help with timer


Recommended Posts

hello, I'm very new to autoit, I only had experience with java language. But I'm trying to make a timer. So I'll explain what I'm trying to do:

1) the first 7 seconds (after I pressed the button) should show up normally 

2) the following 80 seconds should show up with an orange background but when 1) is finished the timer should be resetted and start counting to 80 with the orange background

3) then if 2) is finished the timer should be resseted to and start counting to 6 with a red background

4) finally if 3) is finished the timer should reset again and start counting ip to 8minutes and I want it so it displays minutes : seconds

5) after all this is finished it should start from the beginning again

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

;==> Set our $font variable
Global $font
$font = "Arial Black"

;Constants
Const $sleepLen = 100
; New variables
Dim $check1 = False
Dim $check2 = False
Dim $check3 = False
Dim $check4 = False
Dim $botcounter = 0

;==> Create our Graphic User Interface
;Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$varWindow = GUICreate("Jungle Timers Deluxe", 150, 400, 1675, 30)
$startbutton = GUICtrlCreateButton("start bot", 10, 10, 100, 50, $BS_MULTILINE)
$varButtonTopmost = GUICtrlCreateButton("window topmost", 10, 60, 100, 50)
$varButtonNormal = GUICtrlCreateButton("window normal", 10, 110, 100, 50)
$varLoop = True

;==> Display our Graphic User Interface.
GUISetState(@SW_SHOW)

While $varLoop
$varMessage = GUIGetMsg()
Select
Case $varMessage = $GUI_EVENT_CLOSE
$varLoop = False
Exit
Case $varMessage == $varButtonTopmost
_Button_Topmost_Clicked()
Case $varMessage == $varButtonNormal
_Button_Normal_Clicked()
EndSelect

$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
CLOSEClicked()
Case $startbutton
; Start the timer
$check1 = True
; Reset the counter
$botcounter = 0
; Delete the controls and make the new ones
$bot = GUICtrlCreateLabel("Bot active:", 10, 165)
GUICtrlDelete($startbutton)
Global $botlabel = GUICtrlCreateLabel("0", 15, 180, 50, 40)
GUICtrlSetFont(-1, 22, 500, $font)
EndSwitch
sleep($sleepLen)
check1()
WEnd

Func check1()
If $check1 Then
$botcounter += 1
If $botcounter = (1000/$sleepLen)*7 Then
                    $botcounter = 0
                    $check2 = True
                EndIf
; Update the label & font
                If Mod($botcounter, (1000/$sleepLen)) = 0 Then
                                GUICtrlSetData($botlabel, Round($botcounter/(1000/$sleepLen)))
EndIf
                check2()
                if $check2 = True then
                $check1 = False
                endif
EndIf
EndFunc

Func check2()
        if $check2 then
            $botcounter += 1
            GUICtrlSetBkColor($botlabel, 0xff9900)
            If $botcounter = (1000/$sleepLen)*80 Then
; Set the back color
                GUICtrlSetBkColor($botlabel, 0x66ccff)
                $botcounter = 0
                $check3 = True
            EndIf
            If Mod($botcounter, (1000/$sleepLen)) = 0 Then
                                GUICtrlSetData($botlabel, Round($botcounter/(1000/$sleepLen)))
EndIf
EndIf
        check3()
EndFunc

Func check3()
        if $check3 then
            If $botcounter = (1000/$sleepLen)*6 Then
; Set the back color
                GUICtrlSetBkColor($botlabel, 0xff0000)
                $botcounter = 0
                $check4 = True
            EndIf
            If Mod($ybluebuffcounter, (1000/$sleepLen)) = 0 Then
                                GUICtrlSetData($botlabel, Round($botcounter/(1000/$sleepLen)))
EndIf
EndIf
        check4()
EndFunc

Func check4()
        if $check4 then
            If $botcounter = (1000/$sleepLen)*6 Then
; Set the back color
                GUICtrlSetBkColor($botlabel, 0xff0000)
                $botcounter = 0
            EndIf
            If Mod($botcounter, (1000/$sleepLen)) = 0 Then
                                GUICtrlSetData($botlabel, Round($botcounter/(1000/$sleepLen)))
EndIf
EndIf
EndFunc

Func _Button_Topmost_Clicked()
WinSetOnTop($varWindow,"",1)
EndFunc

Func _Button_Normal_Clicked()
WinSetOnTop($varWindow,"",0)
EndFunc



; Finished! 

I know it's not finished the code but I can't even get numer 2)

please help me   :ermm:

(oh and btw the second code has 2 extra buttons to choose if it should be topmost or not)

Edited by MrBrasta
Link to comment
Share on other sites

Still know what you want this for...

'?do=embed' frameborder='0' data-embedContent>>

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

  • Moderators

MrBrasta,

Which part of:

 

"Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above"

is hard to understand? :huh:

Do NOT start a third thread on this - our patience has limits. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...