rafoster Posted January 21, 2006 Posted January 21, 2006 Hello, I am brand new to scripting, and I am working my way through my second AutoIT Script and trying to clean it up. Basically, I was injecting long Sleep commands into my script to allow time for IE browser loads. This of course is not the ideal situation, as if the page loads, why wait? And of course, on a slow link the whole script will get bollocksed. So, after reading the forums here I decided to try the StatusBarGetText command to determine when the page had finished loading. It seems very squirrely, however... and it's probably because I am just not doing it right. Func BrowserWaitUntilDone() $BrowserDone = StatusBarGetText("Internet Explorer", "", 1) If $BrowserDone = "Done" Then Sleep("100") EndIf EndFunc If I then put BrowserWaitUntilDone() into my script, it should work? Am I using a function the wrong way? Should I be using a subroutine of some kind? Please excuse the newbness, and thank you in advance for the help!
greenmachine Posted January 21, 2006 Posted January 21, 2006 Well, assuming the rest of it works, you're going to want to change at least this one thing: Func BrowserWaitUntilDone() $BrowserDone = StatusBarGetText("Internet Explorer", "", 1) While $BrowserDone <> "Done" Sleep(100) WEnd EndFunc As you had it, the function would go through once. If it was already done, it would sleep for a tenth of a second and then end. If it wasn't done, it would simply end. That's not what you want. You want it to wait until it is done, sleeping until then. When it finally is done, you can end. Also, there's no need to put quotes " " around numbers.
rafoster Posted January 21, 2006 Author Posted January 21, 2006 Well, assuming the rest of it works, you're going to want to change at least this one thing:Func BrowserWaitUntilDone() $BrowserDone = StatusBarGetText("Internet Explorer", "", 1) While $BrowserDone <> "Done" Sleep(100) WEndEndFuncAs you had it, the function would go through once. If it was already done, it would sleep for a tenth of a second and then end. If it wasn't done, it would simply end. That's not what you want. You want it to wait until it is done, sleeping until then. When it finally is done, you can end. Also, there's no need to put quotes " " around numbers.Awesome! What exactly does "WEnd" do? Does that just mean end the loop once the criteria has been met? In this case, loop until $BrowserDone = "Done"?Thanks a lot!
greenmachine Posted January 21, 2006 Posted January 21, 2006 Yes, WEnd is the End to the While (get it? WhileEnd). So yes again on your second statement - loop until $BrowserDone = "Done".
theguy0000 Posted January 21, 2006 Posted January 21, 2006 (edited) For more clarification on the While loop: http://www.autoitscript.com/autoit3/docs/keywords/While.htmcheck out http://www.autoitscript.com/autoit3/docs/i.../lang_loops.htm for more info on loops in AutoIt.By the way, you might be coming from a background of VB or something similar? "Subroutines" are referred to as UDFs (User Defined Functions) in Autoit. Matt Edited January 21, 2006 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ACalcutt Posted January 21, 2006 Posted January 21, 2006 have you looked at the Internet explorer automation udf? it has something to wait untill the page loadshttp://www.autoitscript.com/forum/index.php?showtopic=13398 Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
rafoster Posted January 21, 2006 Author Posted January 21, 2006 @theguy0000 - Thank you very much! I have been wrestling with that for awhile! I don't have a programming background, I've been in IT Hardware/Network Infrastructure operations for 7 years now, and have literally done everything by hand except for NT Batch files and scripts like Kixstart. This is pretty new to me... I have to unlearn a lot of stuff it looks like. @ACalcutt I am going through that UDF Library just now! Thank you for the link. Awesome forum, you guys are great... I have a lot of reading to do it looks like, I really appreciate the help.
sambrown Posted September 3, 2008 Posted September 3, 2008 Well i am new in the field of javascript and i am a asp.net developer. Well coding in C# or visual basic is much simpler than doing work in javascript. This scripting language is very tuf to understand without intellisense. But as i came to know after vs2008 it is possible to write them and compile them in a good ways.Thank yousambrownCrack Cocaine
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