JakeLynagh Posted January 23, 2008 Share Posted January 23, 2008 I have a script that automatically registers a number of times to a website generating random usernames. How can I make it save a log of all of the usernames it generates to a .txt file? Thanks. Link to comment Share on other sites More sharing options...
Rad Posted January 23, 2008 Share Posted January 23, 2008 (edited) ;Append a line of text to the end of a previously opened text file.FileWrite("filename", "text")You should probrably put this in the user creation function.$FileLocation = @scriptdir & "\names.txt" ... Func AddName() $name = GenRandomName() FileWrite($FileLocation, $name) EndfuncThen you could use FileReadLine() and read in the lines to an array, and check if a random name is already taken by comparing the random name to each item in the array. Edited January 23, 2008 by Rad Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 ;Append a line of text to the end of a previously opened text file. FileWrite("filename", "text") You should probrably put this in the user creation function. $FileLocation = @scriptdir & "\names.txt" ... Func AddName() $name = GenRandomName() FileWrite($FileLocation, $name) Endfunc Then you could use FileReadLine() and read in the lines to an array, and check if a random name is already taken by comparing the random name to each item in the array. Sorry, I have absolutely no idea what any of that means... This is only the second thing I have written in Autoit I am still learning the functions. This is what I have: $o_IE = _IECreate () $site = ("https://www.website/register") _IENavigate ($o_IE, $site) MouseClick("left", 400, 100 ) Dim $list[6] = ["John", "Mary", "Suzy", "Stacy", "Peter", "Phill"] $user = $list[Random(0, 6, 1)] $number = random(1000, 9999, 1) Send("{tab}{tab}{tab}{tab}" & $user & $number & "{tab}Password{tab}Password" & $user & $number & "@hotmail.com" "{tab}{enter}") Can you please let me know what I need? Link to comment Share on other sites More sharing options...
Rad Posted January 23, 2008 Share Posted January 23, 2008 (edited) Alright, well the main function I want you to look at is FileWrite. The first parameter is the location "C:\Your File.txt" and the second is the name you used, lets say John.Since you determine the name randomly you would need to keep track of it. Then you would write the name to a file, so that you can later check to see if the name is already registered.Try here, stuff added in Bold for you to see.$o_IE = _IECreate () $site = ("https://www.website/register") _IENavigate ($o_IE, $site) MouseClick("left", 400, 100 ) Dim $list[6] = ["John", "Mary", "Suzy", "Stacy", "Peter", "Phill"] $user = $list[Random(0, 6, 1)] $number = random(1000, 9999, 1) [b]$username = $user & $number[/b] Send("{tab}{tab}{tab}{tab}" & [b]$Username[/b] & "{tab}Password{tab}Password" & [b]$Username[/b] & "@hotmail.com" "{tab}{enter}") [b]FileWrite("C:\NamesUsed.txt", $Username)The filewrite would output a file in your C:\ drive called NamesUsed, and add to the last line of the file John. Edited January 23, 2008 by Rad Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 I see what you have done, and shortening the $username $user and $number waqs an excellent idea, thanks. But I get this: $user = $list[Random(0, 6, 1)] $user = ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Alright, well the main function I want you to look at is FileWrite. The first parameter is the location "C:\Your File.txt" and the second is the name you used, lets say John. Since you determine the name randomly you would need to keep track of it. Then you would write the name to a file, so that you can later check to see if the name is already registered. Try here, stuff added in Bold for you to see. $o_IE = _IECreate () $site = ("https://www.website/register") _IENavigate ($o_IE, $site) MouseClick("left", 400, 100 ) Dim $list[6] = ["John", "Mary", "Suzy", "Stacy", "Peter", "Phill"] $user = $list[Random(0, 6, 1)] $number = random(1000, 9999, 1) [b]$username = $user & $number[/b] Send("{tab}{tab}{tab}{tab}" & [b]$Username[/b] & "{tab}Password{tab}Password" & [b]$Username[/b] & "@hotmail.com" "{tab}{enter}") [b]FileWrite("C:\NamesUsed.txt", $Username) The filewrite would output a file in your C:\ drive called NamesUsed, and add to the last line of the file John. Link to comment Share on other sites More sharing options...
Rad Posted January 23, 2008 Share Posted January 23, 2008 (edited) You need to declare the size of the variable first, I just noticed that you did that but the name of the variable is wrong. Change $list to $user Dim $user[6] = ["John", "Mary", "Suzy", "Stacy", "Peter", "Phill"] $user = $list[Random(0, 6, 1)] I also just realized the bold tags dont even work in the code boxes... Edited January 23, 2008 by Rad Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 Thanks. But I have another error: $user = $list[Random(0, 6, 1)] $list isn't declared again, what do I do with that ^^^ Link to comment Share on other sites More sharing options...
Rad Posted January 23, 2008 Share Posted January 23, 2008 Lol Sorry I'm not awake. Ok, restore the variable back to list and in the Random() function the "max" (second value) needs to be one less than the size of the array. $o_IE = _IECreate () $site = ("https://www.website/register") _IENavigate ($o_IE, $site) MouseClick("left", 400, 100 ) Dim $list[6] = ["John", "Mary", "Suzy", "Stacy", "Peter", "Phill"] $user = $list[Random(0, 5, 1)] $number = random(1000, 9999, 1) [b]$username = $user & $number[/b] Send("{tab}{tab}{tab}{tab}" & [b]$Username[/b] & "{tab}Password{tab}Password" & [b]$Username[/b] & "@hotmail.com" "{tab}{enter}") [b]FileWrite("C:\NamesUsed.txt", $Username) That should work, good luck I'm going back to bed. Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 Okay, now that Rad's gone to bed can anyone help me with this?It says error in expression.I have changed password to:$password = random(10000, 99999, 1)And the error is in:Send("{tab}{tab}{tab}{tab}" & $username & "{tab}" & $password & "{tab}" & $password & "" & $username & "@hotmail.com" "{tab}{enter}")Thanks. Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 Surely someone knows what the error is in this string: Send("{tab}{tab}{tab}{tab}" & $username & "{tab}" & $password & "{tab}" & $password & "" & $username & "@hotmail.com" "{tab}{enter}") Link to comment Share on other sites More sharing options...
JakeLynagh Posted January 23, 2008 Author Share Posted January 23, 2008 It looks really simple, but as I say I am new to this... Anyone? Link to comment Share on other sites More sharing options...
glasglow Posted January 27, 2008 Share Posted January 27, 2008 password & "" & $....maybe right there with the double quotes 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