loop21 Posted January 10, 2010 Share Posted January 10, 2010 Hello im from Germany and i hope my english will be enough good. So i want to script a loop of 2minute. That loop starts with the timer (can be hidden without msgbox or else), that timer begins to count. After it starts the mainprocess (this loop i already has scripted) is going on until is over. The script is waiting for the first loop of 2min. If the 2min are over, it will launch a new loop of 2min and the same mainprocess. _2min loop starts _mainprocess starts and end (the time is variable but not longer than 2min) _2min are over and it starts the same 2min loop with mainprocess You see my problem is that the time of the mainprocess is variable. (sleep function is useless) I hope you can help me. (maybe with #AdlibEnable) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 10, 2010 Moderators Share Posted January 10, 2010 (edited) loop21,Welcome to the Autoit forum. You need an idle loop to fill in the time between the process ending and the 2min timer expiring. Here is a "proof of concept" script to show you how to do it:; Provide an escape HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFunc While 1 $iBegin = TimerInit() ; Simulate main process Sleep(5000) ; This is only 5 seconds, but this is proof of concept! Do Sleep(10) Until TimerDiff($iBegin) > 10000 ; Again this is only 10 secs, but this is POC! ; Prove we wait 10 secs ConsoleWrite(@SEC & @CRLF) WEndI hope that helps.M23Edit: Clarity Edited January 10, 2010 by Melba23 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...
loop21 Posted January 11, 2010 Author Share Posted January 11, 2010 (edited) Thanks at first alot, that is what i want. Now for 2min timer: ; Provide an escape HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFunc While 1 $iBegin = TimerInit() ; Simulate main process ; <--- Sleep(5000) ; This is only 5 seconds, but this is proof of concept! ; <--- that's only a example for mainsequence Do Sleep(10) Until TimerDiff($iBegin) > 120000 ; Again this is only 120 secs (2min), but this is POC! ; Prove we wait 120 secs (2min) ConsoleWrite(@SEC & @CRLF) WEnd I hope that's Ok^^ Thanks for the fast reply! Edited January 11, 2010 by loop21 Link to comment Share on other sites More sharing options...
user101 Posted January 11, 2010 Share Posted January 11, 2010 oh this is good it seems to be part of something I was thinking about, lets say we have a never ending while 1 = 1 code running is it possible to implement this timer outside of my main while loop to refresh my browser every lets say 5mins? I already have my code set to auto login etc but the problem is sometime the browser freezes and needs to be refreshed, even better how can I implement this inorder to do the following? if no clicks or mouse movement is taking place the timer will start to countdown from 30 seconds if there is movement the idle state is canceled but if the 30seconds are up without any movement then it will refresh the browser.. this is great lol ive only been at this reading tutorials and stuff and I already have lots of ideas to make my script full proof haha, my logic is all good but how to implement it is my only problem Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2010 Moderators Share Posted January 11, 2010 user101,If you want to check on idle time, look at _Timer_GetIdleTime in the Help file. Using that in a loop will enable you to detect when you have gone a certain time without any keyboard or mouse activity.M23P.S. You are more likely to get help from the "less young" members around here if you were to capitalise and paragraph your post a little. We are not that used to "yoof-riting" and I for one found it quite hard to read. 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...
user101 Posted January 11, 2010 Share Posted January 11, 2010 user101,If you want to check on idle time, look at _Timer_GetIdleTime in the Help file. Using that in a loop will enable you to detect when you have gone a certain time without any keyboard or mouse activity.M23P.S. You are more likely to get help from the "less young" members around here if you were to capitalise and paragraph your post a little. We are not that used to "yoof-riting" and I for one found it quite hard to read. thank you so much this is exactly what I needed Link to comment Share on other sites More sharing options...
anixon Posted January 12, 2010 Share Posted January 12, 2010 Hello im from Germany and i hope my english will be enough good. So i want to script a loop of 2minute. That loop starts with the timer (can be hidden without msgbox or else), that timer begins to count. After it starts the mainprocess (this loop i already has scripted) is going on until is over. The script is waiting for the first loop of 2min. If the 2min are over, it will launch a new loop of 2min and the same mainprocess. _2min loop starts _mainprocess starts and end (the time is variable but not longer than 2min) _2min are over and it starts the same 2min loop with mainprocess You see my problem is that the time of the mainprocess is variable. (sleep function is useless) I hope you can help me. (maybe with #AdlibEnable) I use this routine to exit at GUI Menu it will give you an idea how the timer works in this situation expandcollapse popup#include <WindowsConstants.au3> Global $EndMenuTime = 5000 ;//Set this variable for the elapese time Global $sHelp = "[url="http://www.autoitscript.com/forum/"]http://www.autoitscript.com/forum/[/url]" _DemoScript() Func _DemoScript() While 1 ;//Exit Menu After nn Minutes Nil Activity Local $MenuCycle = _TimeToTicks(@HOUR, @MIN, @SEC) Local $MenuEndCycle = $MenuCycle + $EndMenuTime ;//Paint the Panel GUICreate("Your Title", 340, 380, -1, -1) GUISetBkColor(0xE0FFFF) GUISetState() ;//Your User Input Code ; ; ; ; ;//Help $sEmailSmsHelp = GUICtrlCreateButton("Help", 175, 350, 65, 25) GUICtrlSetTip(-1, "Link to " & "Your Title" & " 'Help' [Internet Access Required] ", "Help", 1) GUICtrlSetColor(-1, 0x008040) ;Green ;//Close $Exit = GUICtrlCreateButton("Close", 255, 350, 65, 25) While 1 ;//Exit after nn Minutes If _TimeToTicks(@HOUR, @MIN, @SEC) >= $MenuEndCycle Then GUIDelete() ExitLoop (2) EndIf ;//Read the Input Message $msg = GUIGetMsg() Select ;//Exit the Application Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit GUIDelete() ExitLoop (2) Case $msg = $sEmailSmsHelp GUIDelete() ShellExecuteWait($sHelp) ExitLoop EndSelect WEnd WEnd EndFunc 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