Sign in to follow this  
Followers 0
Reveille

Help splitting a string

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by FreeFry

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0