dandymcgee Posted December 7, 2006 Posted December 7, 2006 Hey everyone, I haven't been on for almost 3 weeks now, so I'm glad to get a chance to read through the new posts again. Every once in a while I search the AutoIt forums for some kind of timer function to time things in minutes and seconds (rather than just milliseconds like TimerDiff() returns). I like to solve the Rubik's Cube and time myself, and some of those online timers people have made have WWAAYY too many functions. I made this simple GUI for timing myself spacebar can be used to start and stop the timer. Each time the timer is stopped it records the time into an .ini file in the same location as the script. I'm sure the timer function can be easily adapted to be used for any kind of timing you might want to use it for. If this has already been done, please feel free to let me know (I did search the forums looking if there were any obvious timer functions like this one, and found nothing). Hopefully this can be of use to somebody. expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <Date.au3> HotKeySet("{Space}", "Button") HotKeySet("{Del}", "Delete") $Window = GUICreate("Dan's Timer", 371, 150) $label_time = GUICtrlCreateLabel("00:00.00", 140, 32, 196, 68) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") $light = GUICtrlCreateLabel("", 95, 38, 20, 20) GUICtrlSetBkColor($light, 0xFF0000) $Button1 = GUICtrlCreateButton("Start", 144, 90, 89, 25, 0) $button = 0 $minutes = 0 GUISetState() While 1 $msg = GuiGetMsg() Select Case $msg = $Button1 Button() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func Set_Label() $seconds = Round(TimerDiff($timer)/1000, 2) If $minutes = 0 Then If $seconds < 10 Then GUICtrlSetData(3, "00:0" & $seconds) Else GUICtrlSetData(3, "00:" & $seconds) EndIf Else If $minutes < 10 Then If $seconds < 10 Then GUICtrlSetData(3, "0" & $minutes & ":0" & $seconds) Else GUICtrlSetData(3, "0" & $minutes & ":" & $seconds) EndIf Else If $seconds < 10 Then GUICtrlSetData(3, $minutes & ":0" & $seconds) Else GUICtrlSetData(3, $minutes & ":" & $seconds) EndIf EndIf EndIf If $seconds = 60 Then $minutes = $minutes + 1 Global $timer = TimerInit() EndIf EndFunc Func Button() If $button = 0 Then $button = 1 GUICtrlSetData($Button1, "Stop") GUICtrlSetBkColor($light, 0x00FF00) GUICtrlSetData(3, "3") Sleep(1000) GUICtrlSetData(3, "2") Sleep(1000) GUICtrlSetData(3, "1") Sleep(1000) Global $timer = TimerInit() AdlibEnable("Set_Label", 10) Else $Latest_Solve = GUICtrlRead($label_time) IniWrite("Cube Solve Times.ini", "= = = = Cube Solves = = = =", _NowCalc(), " " & $Latest_Solve) AdlibDisable() GUICtrlSetData($Button1, "Start") GUICtrlSetBkColor($light, 0xFF0000) $button = 0 EndIf EndFunc Func Delete() IniWrite("Cube Solve Times.ini", "= = = = Cube Solves = = = =", "DELETE =", "> THE PREVIOUS ENTRY") EndFunc P.S. Current Rubik's Cube record: 45 seconds (Just can't seem to beat it :\) - Dan [Website]
HackerZer0 Posted December 8, 2006 Posted December 8, 2006 pretty inovative idea...i may have a use for this... : ) btw... what's YOUR record??? i prefer to bet money on solving them (over night), and taking them apart and reasembling them in the correct form... noone has ever figured it out so far... lol Earn money on CASHCRATE by sitting around doing nothing..
dandymcgee Posted December 8, 2006 Author Posted December 8, 2006 Lol... that is MY record. I believe the official world record is somewhere around 10.xx sumtin seconds. I have personally solved it in 45 seconds without disassebling, taking off sctickers, etc. (without cheating). I average at about 1 min. 8 sec. Thanks for you comment on the timer, I did play around with it for a couple of mins to attempt making it into a UDF, but it didn't work right, and I was tired. And new ideas for a script/function etc. for me to work on? - Dan [Website]
HackerZer0 Posted December 8, 2006 Posted December 8, 2006 maybe add in a simple notification sound at certain intervals of time, like a "DING" every 10 seconds or somthing Earn money on CASHCRATE by sitting around doing nothing..
FuryCell Posted December 9, 2006 Posted December 9, 2006 Cool. I like the font. Looks like a real digital clock. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
smstroble Posted December 12, 2006 Posted December 12, 2006 45 SECONDS!!! how can you be that fast. it takes me 3 min to solve my rubix cube, i cant get much faster i cant fathom how you turn your cube that fast... MUHAHAHAHAHA
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now