nitekram Posted October 27, 2007 Share Posted October 27, 2007 I would like to add a login timer to a script, but have determined that something is not right with my code. Or something I need to add to my code to make it work the way I think it should work. Here is the example script - you must have a console to see the reaction, but I went ahead and added to the gui. Anyway - run your mouse around in circles in the gui and see how time flys - how can I fix? #include <GuiConstants.au3> $time = 0 GUICreate("", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $lableTime = GUICtrlCreateLabel($time, 50, 50,200,50) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect $time += 1 If Mod($time,1000) = 0 Then ConsoleWrite($time & @CRLF) guictrlSetData($lableTime,$time) EndIf WEnd 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Achilles Posted October 27, 2007 Share Posted October 27, 2007 (edited) #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetOnEvent($GUI_EVENT_CLOSE, '_Exit') $lableTime = GUICtrlCreateLabel(0, 50, 50,200,50) GUISetState() $time = TimerInit() $index = 0 While 1 If TimerDiff($time) > $index * 1000 Then $index += 1 ConsoleWrite($time & @CRLF) GuictrlSetData($lableTime, TimerDiff($time) / 1000) EndIf WEnd Func _Exit() Exit EndFunc I added a timer instead of just using the loop. I also set it to GuiEventMode()... I'm guessing you're former problem had something to do with the GuiGetMsg(). I think that command waits a while and then goes past (returning $msg as 0 or something). But sometimes, if their is a message it will not pause at all when it gets to the GuiGetMsg() command. I hope that made some sense... EDIT: Fixed tags Edited October 27, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
nitekram Posted October 27, 2007 Author Share Posted October 27, 2007 #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetOnEvent($GUI_EVENT_CLOSE, '_Exit') $lableTime = GUICtrlCreateLabel(0, 50, 50,200,50) GUISetState() $time = TimerInit() $index = 0 While 1 If TimerDiff($time) > $index * 1000 Then $index += 1 ConsoleWrite($time & @CRLF) GuictrlSetData($lableTime, TimerDiff($time) / 1000) EndIf WEnd Func _Exit() Exit EndFunc I added a timer instead of just using the loop. I also set it to GuiEventMode()... I'm guessing you're former problem had something to do with the GuiGetMsg(). I think that command waits a while and then goes past (returning $msg as 0 or something). But sometimes, if their is a message it will not pause at all when it gets to the GuiGetMsg() command. I hope that made some sense... EDIT: Fixed tags That works - thanks. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
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