Reveille Posted May 26, 2007 Share Posted May 26, 2007 Ive never made a real program with AutoIt before and Im having some trouble splitting a String from a txtBox. My goal here is to take the String from a AutoIt form txtBox and type (Send) the String letter-by-letter. I receive no errors but I believe Im getting an infinate loop of Null substrings. Should I be using the StingMid function for this? My Code: CODE Dim $UN = "abc" Dim $subStr = "" Dim $i = 0; Dim $UNLen = StringLen($UN) MsgBox(4096, "UserName Length", $UNLen) $i = 0 While $i < $UNLen $subStr = StringMid($UN,$i,1) ;If $subStr NOT=="" Then;//Ive taken this test out for now because the returned substring always seems to be Null MsgBox(4096, "UserName", $subStr) Sleep(Random(200,400,1)) Send($subStr); //type in username element ;EndIf WEnd Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2007 Developers Share Posted May 26, 2007 Dim $UN = "abc" Dim $subStr = "" Dim $UNLen = StringLen($UN) MsgBox(4096, "UserName Length", $UNLen) For $i = 1 to $UNLen $subStr = StringMid($UN, $i, 1) Sleep(Random(200, 400, 1)) Send($subStr) ; //type in username element Next SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Reveille Posted May 26, 2007 Author Share Posted May 26, 2007 Thanks Link to comment Share on other sites More sharing options...
FreeFry Posted May 26, 2007 Share Posted May 26, 2007 (edited) Hmm, seems like you're used to a syntax of another language... Dim $UN = "abc" Dim $subStr = "" Dim $i = 0; Dim $UNLen = StringLen($UN) MsgBox(4096, "UserName Length", $UNLen) $i = 0 While $i < $UNLen $subStr = StringMid($UN,$i,1) ;If $subStr NOT=="" Then;//Ive taken this test out for now because the returned substring always seems to be Null MsgBox(4096, "UserName", $subStr) Sleep(Random(200,400,1)) Send($subStr); //type in username element ;EndIf WEnd oÝ÷ Ø*.ÖÞjëh×6 Dim $UN = "abc" MsgBox(4096, "UserName Length", StringLen($UN)) For $i = 1 To StringLen($UN) MsgBox(4096, "UserName", StringMid($UN,$i,1)) Sleep(300) Send($subStr) Next I'd prefer not using so many variables, though using variables to store a string length is faster than running the StringLen() function several times in a loop(though one extra time is not that bad, as in this case), depends on how many times it's called in a loop basically... Edited May 26, 2007 by FreeFry Link to comment Share on other sites More sharing options...
Zedna Posted May 26, 2007 Share Posted May 26, 2007 Even simpler way: Dim $UN = "abc" Dim $subStr = "" $UN = StringSplit($UN,'') For $i = 1 to $UN[0] $subStr = $UN[$i] Sleep(Random(200, 400, 1)) Send($subStr) ; //type in username element Next Resources UDF ResourcesEx UDF AutoIt Forum Search 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