Reading and moving text

05/24/2014 18:13 goldenapple007#1
I want to make something , but I need to be able to read text in a .txt file.
the text are username's and passwords, they are in this format:

txt file :

username1|password1
username2|password2
username3|password3
....

How can I move the first line ( username1|password1 ) to another txt file and make the second line (username2|password2) the first line.
so it will be something like this

txt file: txt file 2:
username2|password2 username1|password1
username3|password3
...

and then I need to be able to split the username and password, so that I can use it to log in.
so that I get something like this:
$user = username1
$pass = password1
05/24/2014 18:35 alpines#2
Wow, that's one of the most basic things in AutoIt...
Code:
#include <File.au3>
#include <Array.au3>

;Get Usernames and Passwords.

;~ Local $aSplittenFile[_FileCountLines("file1.txt")]

;~ For $i = 0 To UBound($aSplittenFile) - 1
;~ 	$aSplittenFile[$i] = FileReadLine("file1.txt", $i + 1)
;~ Next

;~ Local $aSplits[UBound($aSplittenFile)][2]

;~ For $i = 0 To UBound($aSplittenFile) - 1
;~ 	$aTmp = StringSplit($aSplittenFile[$i], "|", 2)
;~ 	$aSplits[$i][0] = $aTmp[0]
;~ 	$aSplits[$i][1] = $aTmp[1]
;~ Next

_ArrayDisplay($aSplits)

;Delete first line and move it to the 2nd file.

;~ $sFile = FileReadLine("file1.txt", 1)
;~ _FileWriteToLine("file1.txt", 1, "", 1)

;~ FileWrite("file2.txt", $sFile)
05/24/2014 20:05 goldenapple007#3
Quote:
Originally Posted by alpines View Post
Wow, that's one of the most basic things in AutoIt...
Code:
#include <File.au3>
#include <Array.au3>

;Get Usernames and Passwords.

;~ Local $aSplittenFile[_FileCountLines("file1.txt")]

;~ For $i = 0 To UBound($aSplittenFile) - 1
;~ 	$aSplittenFile[$i] = FileReadLine("file1.txt", $i + 1)
;~ Next

;~ Local $aSplits[UBound($aSplittenFile)][2]

;~ For $i = 0 To UBound($aSplittenFile) - 1
;~ 	$aTmp = StringSplit($aSplittenFile[$i], "|", 2)
;~ 	$aSplits[$i][0] = $aTmp[0]
;~ 	$aSplits[$i][1] = $aTmp[1]
;~ Next

_ArrayDisplay($aSplits)

;Delete first line and move it to the 2nd file.

;~ $sFile = FileReadLine("file1.txt", 1)
;~ _FileWriteToLine("file1.txt", 1, "", 1)

;~ FileWrite("file2.txt", $sFile)
Thanks a lot!
But by getting the username and password I ment that I could let the bot enter the username and password in the game.
with: Send or something
And not show them in ArrayDisplay.
also; is it possibe to only let it do the action when file2 is empty?

sorry if I wasn't clear , my english isn't good :-(
05/24/2014 20:50 alpines#4
_ArrayDisplay was just there for debugging purposes and showing how they are listed.
Yes you can enter that in a game, simply focus the box where you want to put it in and either use ControlSend or Send.

Yes it is, you can do
Code:
If Not FileGetSize("file2.txt") Then ;file is empty.
05/24/2014 21:16 goldenapple007#5
Quote:
Originally Posted by alpines View Post
_ArrayDisplay was just there for debugging purposes and showing how they are listed.
Yes you can enter that in a game, simply focus the box where you want to put it in and either use ControlSend or Send.

Yes it is, you can do
Code:
If Not FileGetSize("file2.txt") Then ;file is empty.
Now I get it I think:

$aTmp[0] = the username
$aTmp[1] = the password

Works fine for now, Gonna see if it works in the bot tommorow.
05/24/2014 23:38 fear-x#6
no offence [Only registered and activated users can see links. Click Here To Register...] but if you cant do simple file read / string split... your bot is gonna suck ass. im not saying im pro , ofcourse i was there years ago too in the ultra-beginner gear, ofcourse im not saying quit... il say... KEEP GOING ! but you MUST try do it yourself ! atleast try trial & error until your head blows up into million pieces and u have no other way but to come here and ask for help ! :)

but best of luck ! ;)
05/25/2014 08:22 goldenapple007#7
Quote:
Originally Posted by fear-x View Post
no offence [Only registered and activated users can see links. Click Here To Register...] but if you cant do simple file read / string split... your bot is gonna suck ass. im not saying im pro , ofcourse i was there years ago too in the ultra-beginner gear, ofcourse im not saying quit... il say... KEEP GOING ! but you MUST try do it yourself ! atleast try trial & error until your head blows up into million pieces and u have no other way but to come here and ask for help ! :)

but best of luck ! ;)
I know I suck xD
But all the bot needs is auto login,config, and image detection using ImageSearch. all of them are really easy... The only part I couldnt' do myself is the auto login.
And It's for personal use, so I don't care if it isn't 100% stable.
But still I hope it's gonna be stable, made a smaller bot with same things in it already and it never crashed so far.
05/25/2014 11:29 mlukac89#8
For what game u need that ?
And better use .ini files to store username and password it much simpler that this.
05/25/2014 13:40 goldenapple007#9
Quote:
Originally Posted by mlukac89 View Post
For what game u need that ?
And better use .ini files to store username and password it much simpler that this.
for LOL.
I don't think ini files are mutch simpler.
cus there are 100+ acc's gonna be in the list.
05/25/2014 15:39 alpines#10
Certainly, INI files are easier to handle, because it's easier to read them otherwise you have to use the long way as I did.