|
You last visited: Today at 22:54
Advertisement
Reading and moving text
Discussion on Reading and moving text within the AutoIt forum part of the Coders Den category.
05/24/2014, 18:13
|
#1
|
elite*gold: 0
Join Date: May 2014
Posts: 84
Received Thanks: 6
|
Reading and moving text
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
|
#2
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
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
|
#3
|
elite*gold: 0
Join Date: May 2014
Posts: 84
Received Thanks: 6
|
Quote:
Originally Posted by alpines
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
|
#4
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
_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
|
#5
|
elite*gold: 0
Join Date: May 2014
Posts: 84
Received Thanks: 6
|
Quote:
Originally Posted by alpines
_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
|
#6
|
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,093
|
no offence but if you cant do simple file read / string split... your bot is gonna suck ***. 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
|
#7
|
elite*gold: 0
Join Date: May 2014
Posts: 84
Received Thanks: 6
|
Quote:
Originally Posted by fear-x
no offence but if you cant do simple file read / string split... your bot is gonna suck ***. 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
|
#8
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
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
|
#9
|
elite*gold: 0
Join Date: May 2014
Posts: 84
Received Thanks: 6
|
Quote:
Originally Posted by mlukac89
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
|
#10
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
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.
|
|
|
Similar Threads
|
[Poll] Reading data from text file or database?
04/01/2011 - SRO Coding Corner - 11 Replies
Hi,
I'm currently facing a little choice about how I should read the data of silkroad. So I hope that I can get a clear answer with this thread/poll.
Well as you might know I'm using C++ and currently I'm reading the data into the memory which is just a big list of for example npc position objects.
So yesterday I created a little test and I inserted all the npc positions into an MySQL database (version 5.1) and I used 10 different id's of npcs to get the positions. I runned this test...
|
All times are GMT +2. The time now is 22:54.
|
|