c4mpi Posted February 23, 2010 Posted February 23, 2010 Hi, I am new to autoit and want to do a sleep without stopping the script. I saw on another forum that I can do this using TimerInit() and TimerDiff. But I dont understand how to use it, I need it to wait 1 hour then run a part of my script. I also need a way to find words on a site. Like search it up. I appreciate all help (sorry for my bad english)
jchd Posted February 23, 2010 Posted February 23, 2010 Welcome to the AutoIt forum! Sleep() will pause (but not terminate) the script. While sleeping, no significant CPU is consumed until timeout and execution resumes on the next instruction after Sleep. So Sleep() is for you, AFAICS. Timer* functions are what they're called: timing functions. Execution continues after TimerInit and you may call TimerDiff anytime to know the elapsed time from TimerInit. To grab text from a source html, you may use _IE* or Inet* functions. E.g. _IEAttach and _IEDocReadHTML, or _InetGetSource or InetRead or InetGet then use StringRegexp or whatever String* functions suits your need to dissect things. Anyway, your best friend here is no more Google: when it relates to AutoIt, your best friend by far is the help file! Almost everything you can find on the forum comes from there. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
BrettF Posted February 23, 2010 Posted February 23, 2010 Welcome to the forums. I'm a big fan of you learning how to do it by thinking it through yourself. So lets go through the logic process and see if you can get an answer. So if you look at the functions in the help file you will see that TimerInit() will start the timer. If we look at what TimerDiff() does we can see that it returns the time (in milliseconds) from when you initiated it with TimerInit(). So with a conditional statement we can find out when TimerDiff is equal to an hour. But what if the script works out the difference at 1 hour and 1ms? Instead of using just = in our conditional statement we should use >=. If TIMER is GREATER or EQUAL to 1 HOUR (in milliseconds). So we can check it once but how do we check it more than one time? The simplest way will be with a While...Wend loop. Remember you don't want to keep initiating your timer, so keep TimerInit out of the loop. I think I've given you enough information and hints to work this out. Give it a go and post back if you have any problems. Remember to post your code Cheers, Brett 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!
c4mpi Posted February 23, 2010 Author Posted February 23, 2010 Hi, I am new to autoit and want to do a sleep without stopping the script. I saw on another forum that I can do this using TimerInit() and TimerDiff. But I dont understand how to use it, I need it to wait 1 hour then run a part of my script. I also need a way to find words on a site. Like search it up.I appreciate all help (sorry for my bad english)Thanks for the help, I understand how you can find a text using source code now.
c4mpi Posted February 23, 2010 Author Posted February 23, 2010 Welcome to the forums. I'm a big fan of you learning how to do it by thinking it through yourself. So lets go through the logic process and see if you can get an answer.So if you look at the functions in the help file you will see that TimerInit() will start the timer. If we look at what TimerDiff() does we can see that it returns the time (in milliseconds) from when you initiated it with TimerInit(). So with a conditional statement we can find out when TimerDiff is equal to an hour. But what if the script works out the difference at 1 hour and 1ms? Instead of using just = in our conditional statement we should use >=. If TIMER is GREATER or EQUAL to 1 HOUR (in milliseconds).So we can check it once but how do we check it more than one time? The simplest way will be with a While...Wend loop. Remember you don't want to keep initiating your timer, so keep TimerInit out of the loop.I think I've given you enough information and hints to work this out. Give it a go and post back if you have any problems. Remember to post your code Cheers,BrettThanks for the hints and help, I will think trough this and post a reply if I cant find a solution
c4mpi Posted February 23, 2010 Author Posted February 23, 2010 (edited) Thanks for the hints and help, I will think trough this and post a reply if I cant find a solution Okey so I made a quick script out of what you said $timer = TimerInit() ; this marks the start While 1 $timed = TimerDiff($timer) If $timed > 3000 Then MYSCRIPT HERE $timer = TimerInit() EndIf WEnd Would this be able to run in the "background", what I mean with this is; will this pause the script? And may I somehow set the timer to one hour in a easier way then writing it in ms? thanks Edited February 23, 2010 by c4mpi
PsaltyDS Posted February 23, 2010 Posted February 23, 2010 One hour: If $timed > 1000 * 60 * 60 Then Come on, the math isn't hard! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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