jerem488 Posted January 17, 2009 Share Posted January 17, 2009 Hi, I have a loop and I have a timer() func. I would integrate this timer func in my first loop. $timer = TimerInit() While TimerDiff($timer) < $duree ; I want put my func timer here ! WEnd Func Timer() While 1 _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs ) $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) ToolTip("Temps restant : " & $TempsRestant,1000,70) Sleep(1000) WEnd EndFunc But like I have my while in my timer() func, my script don't continue thanks Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2009 Moderators Share Posted January 17, 2009 jerem488, Does this help?$duree = ##### $timer = TimerInit() While If TimerDiff($timer) < $duree Then _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs ) $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) ToolTip("Temps restant : " & $TempsRestant,1000,70) EndIf WEnd M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jerem488 Posted January 17, 2009 Author Share Posted January 17, 2009 no, not really.... because the script I execute in the first loop exceeds 1second ! ! So the timer change every (((the time of the loop))) ! ! Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2009 Moderators Share Posted January 17, 2009 jerem488, Have you looked at using AdLib? It sounds as though it might be what you are looking for. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Demonic Posted January 17, 2009 Share Posted January 17, 2009 $timer = TimerInit() $timerDuration = 1000 ; 1 second While 1 If TimerDiff($timer) > $timerDuration Then $timer = TimerInit() ConsoleWrite("Resetting Timer" & @CR) ; If over the timer, reset Else ConsoleWrite("Executing Code" & @CR) ; Else, Execute the code repeatedly EndIf Sleep(100) WEnd Is that what you're going for? In that case, to enable your second "loop", you would add an additional statement to the line: If TimerDiff($timer) > $timerDuration Then in order to make it more specific. Link to comment Share on other sites More sharing options...
jerem488 Posted January 17, 2009 Author Share Posted January 17, 2009 (edited) I defined the execution time of my script with the $duree variable in a messagebox. And I want a timer of the remaining time in seconds. $duree = GUICtrlCreateInput("0", 75, 60, 50, 20) $timer = TimerInit() While TimerDiff($timer) < $duree Sleep(Random(500,1000)) MouseMove(742, 914) Sleep(500) MouseClick("left") Sleep(Random(9000,10000)) MouseMove(290, 220) Sleep(Random(1200,1500)) MouseClick("left") Sleep(Random(1000, 1200)) MouseMove(742, 914) WEnd Edited January 17, 2009 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
FireFox Posted January 17, 2009 Share Posted January 17, 2009 ...? $timer = TimerInit() While TimerDiff($timer) < $duree ; I want put my func timer here ! Timer() WEnd Func Timer() While 1 _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs ) $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) ToolTip("Temps restant : " & $TempsRestant,1000,70) Sleep(1000) WEnd EndFunc Cheers, FireFox. Link to comment Share on other sites More sharing options...
jerem488 Posted January 18, 2009 Author Share Posted January 18, 2009 Euh................... How expalin the problem........... I have already a loop that lasts about 3minutes. And during this loop, I want in fact a timer of the remaining time in seconds.... Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Pain Posted January 18, 2009 Share Posted January 18, 2009 (edited) A very simple example. For $i = 0 To 9 Sleep(1000) ConsoleWrite(9-$i &@CR) Next I know it's very unreliable but you get the point. Edited January 18, 2009 by Pain Link to comment Share on other sites More sharing options...
jerem488 Posted January 18, 2009 Author Share Posted January 18, 2009 yes ! ! But the loop continue when the timer is finished ! ! Nearly me, I want the timer tun when the loop run ! Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2009 Moderators Share Posted January 18, 2009 jerem488, Is this what you are looking for?$timer = TimerInit() While TimerDiff($timer) < $duree _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs ) $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) ToolTip("Temps restant : " & $TempsRestant,1000,70) ; Other functions which run in the loop WEnd ToolTip("") Your loop will now run for $duréé ms and carry out other functions and the ToolTip will give $TempsRestant throughout. Do not forget to clear the ToolTip after the loop. ;-) Si cela n'est pas la solution, explique en francais parce que je n'ai evidemment pas compris la question! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2009 Moderators Share Posted January 19, 2009 jerem488, Now I understand (via PM in French) what you want, my earlier suggestion of AdLib seems to be the answer. This is an example which shows how to go about it:GUICreate("AdLib Test", 200, 200) $Label1 = GUICtrlCreateLabel("Main Loop Count: 0", 10, 10, 180, 20) $Label2 = GUICtrlCreateLabel("Timer Count: 0", 10, 110, 180, 20) GUISetState() AdlibEnable("Timer", 1000) $Begin = TimerInit() $i = 1 While 1 Sleep(20000); Replaces your loop functions GUICtrlSetData($label1, "Main Loop Count: " & $i) $i += 1 WEnd Func Timer() GUICtrlSetData($Label2, "Timer Count: " & Int(TimerDiff($Begin) / 1000)) EndFunc Hope that solves the problem. Ask again if there is something you are unclear about. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jerem488 Posted January 19, 2009 Author Share Posted January 19, 2009 (edited) Yes ! ! It's this ! Very thanks ! ! I didn't know this function. Now, I could use ! Topic resolved ]]]]]]]]]]] ! ! ! Thnks M23 ! Edited January 19, 2009 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2009 Moderators Share Posted January 19, 2009 jerem488, Excellent. 2 things to remember: 1. Do not put too much code in the function called by AdLib. 2. Disable AdLib when you no longer need it or it eats CPU time unnecessarily. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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