eHrgo Posted February 23, 2007 Share Posted February 23, 2007 Hi guys, My problem is quit simple: I want to repeat a function every 10secs, I have a close button to stop that program at anytime.. Thos doesn't work: $Close = GuiCtrlCreateButton..... While GuiGetMsg() not $Close ...Whatever Function Sleep (10000) Wend oÝ÷ Ù«¢+Ø(ÀÌØí ±½ÍôÕ¥ Ñɱ ÉÑ ÕÑѽ¸¸¸¸¸¸()¼(¸¸¹]¡ÑÙÈչѥ½¸)M±À ÄÀÀÀÀ¤)U¹Ñ¥°Õ¥Ñ5Í ¤ôÀÌØí ±½Í( I know this question has been asked a thousand time but i didn't understand how to easily solve it ... We can break with hotkeys at anytime, why can't we with GuiGetMsg? Thanks Sorry for my Bad English. Link to comment Share on other sites More sharing options...
Kickassjoe Posted February 23, 2007 Share Posted February 23, 2007 I don't know if this answers your question, but the program probably will not close because, in the loops it only checks either at the beginning (while loop) or at the end (do-until loop), so there is a very small chance that it is checking for the button to be pressed exactly when you are pressing it... (same for other controls that you are looking for being pressed) What goes around comes around... Payback's a bitch. Link to comment Share on other sites More sharing options...
eHrgo Posted February 23, 2007 Author Share Posted February 23, 2007 Yes, I imagine that ... But some fonction are always working like HotKeySet ... Sorry for my Bad English. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 23, 2007 Moderators Share Posted February 23, 2007 You may want to look at TimerInit()/TimerDiff() for your time periods rather than sleep. Dim $nTimer = TimerInit() While GuiGetMsg() <> $Close If TimerDiff($nTimer) / 1000 >= 10 Then ;.... whatever function // Keep in mind, that while in this function, GUIGetMsg() isn't going to work. $nTimer = TimerInit() EndIf Wend 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. Link to comment Share on other sites More sharing options...
eHrgo Posted February 23, 2007 Author Share Posted February 23, 2007 Thanks a lot! Love those Sorry for my Bad English. Link to comment Share on other sites More sharing options...
eHrgo Posted February 24, 2007 Author Share Posted February 24, 2007 Hum .... I still have a problem: I have now that: $Timer10 = TimerInit() While GuiGetMsg() <> $close GUISetState (@SW_SHOW) If TimerDiff($Timer10) >= 10000 Then Call ('GetPoints') $Timer10 = TimerInit() EndIf Wend oÝ÷ Øjz-êÁºÛhÚ&Èe§¶+m¡Ú0«^½êÚrب^*kzË"´kçZºÚ"µÍÚ[HÝZQÙ]ÙÊ H ÉÝÈ ÌÍØÛÜÙHÔ ÌÍÔÝ] But it obviously don't work ... how can i do that? Thanks a lot Sorry for my Bad English. Link to comment Share on other sites More sharing options...
eHrgo Posted February 24, 2007 Author Share Posted February 24, 2007 (edited) Working with a OnEvent mode! Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent ( $close, 'Terminate') GuiCtrlSetOnEvent ( $Stats, 'Stats') Func Terminate() Exit 0 EndFunc Func Stats() ... Whatever. EndFunc While 1 ..Whatever Wend Edited February 24, 2007 by eHrgo Sorry for my Bad English. Link to comment Share on other sites More sharing options...
xcal Posted February 24, 2007 Share Posted February 24, 2007 You're going to want a Sleep(50) in your While loop, unless cpu usage doesn't matter. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Sykeo Posted February 24, 2007 Share Posted February 24, 2007 (edited) #include <GUIConstants.au3> Dim $Gui_main = GUICreate("woof",150,100,-1,-1) Dim $btn = GUICtrlCreateButton ( "Bark", 45,30,50) Dim $enable = 1 GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $btn If $enable = 1 then AdlibEnable("woot",1000) $enable = 0 Else AdlibDisable() $enable = 1 EndIf EndSelect WEnd Func woot() ConsoleWrite("BLAH BLAH" & @CRLF) EndFunc Edited February 24, 2007 by Sykeo 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