Cambo Posted December 17, 2007 Share Posted December 17, 2007 These boards are on fire! And everyone seems to be extremely helpful!I figured I had one more question pressing on my mind so why not ask it! I'm very new to autoit, and have only been coding altogether for about 5 months, so if the questions I ask seem trivial, please forgive me!I want some kind of loop that sends a certain defined key (using SEND(), very simple) every 60 secs or so (I normally just do Sleep(Random(60000,65000)) or something) but also is constantly (without the sleep) checking for a string (using my newly learned StringRegExp() )Right now I have something like this:While 1 Send("{k}") Sleep(Random(60000,65000)) $lines = FileRead("file.log") If StringRegExp($lines, "A|B|C") Then Sleep(Random(3000,5000)) DoSomethingElse() EndIf WEndBut this only reads the file every 60 seconds. I want it to constantly (no sleep timer) read the file while only every 60 seconds send the key. What else am I missing tonight? Thanks again for the wonderful help! Link to comment Share on other sites More sharing options...
Squirrely1 Posted December 17, 2007 Share Posted December 17, 2007 You make the execution of the thing that sleeps longer to be conditionally executed: Send("{k}") $time = (Random(60000,65000)) $base = TimerInit() While 1 If TimerDiff($base) > $time Then Send("{k}") $time = (Random(60000,65000)) $base = TimerInit() EndIf $lines = FileRead("file.log") If StringRegExp($lines, "A|B|C") Then Sleep(Random(3000,5000)) DoSomethingElse() EndIf WEnd Das Häschen benutzt Radar 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