oozma Posted August 21, 2009 Share Posted August 21, 2009 Hi all, I am looking for a way to perform an action every 14 minutes mid-script. I currently have one function being called in my script that performs a series of keypresses and clicks in a while 1=1 loop, but I want to throw in that it calls a different function every 14 minutes. I've looked through the timer options but it's a little confusing to me as I'm still a bit new to this. One option is looping the function X amount of times to equal 14 minutes, but that number is so high I can't even begin to count it. Any advice would be very much appreciated >_< thank you! Link to comment Share on other sites More sharing options...
Juvigy Posted August 21, 2009 Share Posted August 21, 2009 sleep(840000) will wait 14 min. put it in a loop and after that call the function. That is it. Link to comment Share on other sites More sharing options...
BrettF Posted August 21, 2009 Share Posted August 21, 2009 Persudo: $timer = TimerInit While 1 If TimerDiff($timer) >= 840000 Then $timer = TimerInit() ;do something else ;do something else endif wend Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jvanegmond Posted August 21, 2009 Share Posted August 21, 2009 Just call the _check_timer occasionally. Thanks for the boost Brett. : ) ; initialization of your stuff $timer = TimerInit() While 1 ; Your stuff _check_timer() ; more of your stuff _check_timer() ; more of your stuff _check_timer() Wend Func _check_timer() If TimerDiff($timer) >= 840000 Then $timer = TimerInit() _fire_timer() endif EndFunc Func _fire_timer() ; Logic that goes once every 14 minutes goes here EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
oozma Posted August 21, 2009 Author Share Posted August 21, 2009 Thanks >_< That worked perfectly with a few mods from my stuff. Appreciate it. Link to comment Share on other sites More sharing options...
oozma Posted August 23, 2009 Author Share Posted August 23, 2009 Hi, sorry to bump this up again but I have one more question. Currently with using the above, the script is working excellent. One slight problem... every 4 minutes or so (I lowered the time a bit) it is pressing the key "4" - at all times. I have a hotkey set to turn the script on or off on demand, but the timer and '4' seem to run nonstop even if it's off. Is there a way to only start the timer when I push the 'start' hotkey, and then stop the timer and the '4' from being sent when I push the 'stop' hotkey? I know WHY it's doing it, but when I attempt to fix it, I get a syntax check error WARNING: $timer: possibly used before declaration. Below is what I have... expandcollapse popupHotKeySet("!1","Start") HotKeySet("!3","Stop") Global $go = false Func start() $go = True EndFunc $timer = TimerInit() Func stop() $go = False EndFunc while 1 check() sleep(50) run() sleep(50) wend Func check() If TimerDiff($timer) >= 440000 Then $timer = TimerInit() _fire_timer() endif EndFunc Func _fire_timer() sleep(1000) send("4") sleep(2000) EndFunc Func run() if $go = true Then MouseDown("left") sleep(2500) MouseUp("Left") Send("2") Send("2") Send("2") Send("2") Send("2") Send("2") sleep(1000) Send("1") sleep(1000) EndIf 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