Hello i want to read my email and passw from .txt

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Hello i want to read my email and passw from .txt

02 Jan 2022, 20:45

Hello I was trying to find out how I can read a txtfile with my Emails and passwords saved in the format Email:Password each line will have a different email and password for my different socials and websites I frequent. in my script i will have a hotkey load a specific website and then i want to be able to enter the Email and password in to the email:password fields with a (SendInput, Email) and different hotkey for (SendInput, Password) i have the scripts working for clicking some sites just need to figure out how to read from file and tell that (Email):(Password)
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passwfrom .txt

02 Jan 2022, 23:35

You would use FileRead to read the text file contents into a variable. Then you can split the lines using either a parsing loop or StrSplit() using `n as the delimiter and `r as the character to omit (in case your file uses both). Then you can either use RegExMatch() or StrSplit() again to separate each email from its password based on the : delimiter.
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 00:08

So here is my code it takes Email from Email:Passw and makes a traytip

Code: Select all

fileread, Email, EmailPass.txt
for i, row in Loopobj:=strsplit(Email,"`n","`r"){
	pos:=instr(Row,"m:",,0,1)
traytip,Entering as email, % substr(Row,1,pos), 2, 0x10

return
}
return


I also want to take the password and do same thing but when I run the code for password it get the last password on my email list that contains 7 emails and passw

Code: Select all

 fileread, Email, EmailPass.txt
 for k, v in strsplit(Email,[":"," "])
	if(instr(v,":"))
		emails.=v "`n"
	msgbox % v

	return


How can I read line one but get the password as I already can get the email? And Is it possible to add timestamp for last time that Email password combination used in a traytip?
Thank you so much for your quick response :)
User avatar
TLM
Posts: 1606
Joined: 01 Oct 2013, 07:52
Contact:

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 01:35

You can parse the email & password combinations all in one loop like this:

Code: Select all

fileread, Email, EmailPass.txt

CredArr := { Email : [], Password : [] } ; <-- Credential array to store the emails & passwords
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred 	:= StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
	
	msgbox 	% "Email " i ": " 		CredArr.Email[ i ]
			. "`nPassword " i ": " 	CredArr.Password[ i ] 
}

Return
The CredArr stores the values so you can use them elsewhere later on.
If you want to do everything in one loop, you don't need the storage array:

Code: Select all

fileread, Email, EmailPass.txt

For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred 	:= StrSplit( Row, [ ":", " " ] )
					
	msgbox 	% "Email " i ": " 		Cred.1
			. "`nPassword " i ": " 	Cred.2
}
Please see the docs for further information.
hth
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 11:13

Awesome thank you so much so if i want to only read first row what would i change in that code? also can i use the email in a SendInput,Email from first row then press enter then use the password and use it in a SendInput,Passwordfrom first row?? i tried %Email% and "Email" and wouldnt insert it from the file only would insert the text %Email% and "Email"
User avatar
TLM
Posts: 1606
Joined: 01 Oct 2013, 07:52
Contact:

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 13:41

Blastoise465 wrote:
03 Jan 2022, 11:13
Awesome thank you so much so if i want to only read first row what would i change
You can swap FileRead with FileReadLine:

Code: Select all

FileReadLine, Email, EmailPass.txt, 1

Cred 	:= StrSplit( Email, [ ":", " " ] )

Msgbox % "1st Email: " Cred.1 "`n1st Password: " Cred.2
return
Or use a fixed Array key instead of parsing through each file line

Code: Select all

fileread, Email, EmailPass.txt

Creds 	:= StrSplit( Email, "`n", "`r" )
Cred 	:= StrSplit( Creds.1, [ ":", " " ] )

Msgbox % "1st Email: " Cred.1 "`n1st Password: " Cred.2
return
Or if you use the Storage Array, you can simply use the 1st key values: CredArr.Email.1 & CredArr.Password.1.
Blastoise465 wrote:
03 Jan 2022, 11:13
can i use the email in a SendInput,Email from first row then press enter then use the password and use it in a SendInput,Passwordfrom first row??
You have to use an Expression in SendInput.

Assuming you're using the storage Array an the Enter key as the hotkey:

Code: Select all

FileRead, Email, Email.txt

CredArr := { Email : [], Password : [] }
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred := StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
}
return

Enter: ; Long Form Hotkey
if ( !cnt )
{
	SendInput % CredArr.Email.1	; the % forces expression mode
	cnt := 1
}
else
{
	SendInput % CredArr.Password.1
	cnt := 0
}
return
Enter::SendInput % CredArr[ (cnt:=!cnt) ? "Email" : "Password" ].1 ; Short Form Hotkey
htms
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 15:11

IT works :D Many thanks to you all for the help! and i noticed one thing about the last script it works but it adds a space infront off email and password i tried eliminating spaces but got an error is there a specific way to remove the spaces from you code output? saying wrong password with spaces in front?

Code: Select all

FileRead, Email, Email.txt

CredArr := { Email : [], Password : [] }
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred := StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
}
return

Enter: ; Long Form Hotkey
if ( !cnt )
{
	SendInput % CredArr.Email.1	; the % forces expression mode
	cnt := 1
}
else
{
	SendInput % CredArr.Password.1
	cnt := 0
}
return
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 15:20

Blastoise465 wrote: is there a specific way to remove the spaces from you code output? saying wrong password with spaces in front?
Trim() will remove any leading spaces and tabs from the front and end. Use LTrim() if you specifically only want to trim space from the front end.

Code: Select all

SendInput % Trim(CredArr.Email.1)

It would actually be better to trim them at the time they are added to the array instead of when you send the output:

Code: Select all

CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) )
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 21:36

Ive tried putting both of those scripts in multiple spots and doesnt work sometimes itll only show one character of the email or password

Code: Select all

Find_Image:
	Stop:=0
	While(Stop=0)
		{
			;Loop
			
filereadLine, Email, C:\EmailPass.txt,1

CredArr := { Email : [], Password : [] } ; <-- Credential array to store the emails & passwords
CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
For i, Row in StrSplit( Email, "`n", "`r" )
		
{
	(CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) ));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	Cred 	:= StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )

	msgbox 	% "Email " i ": " 		CredArr.Email[ i ]
			. "`nPassword " i ": " 	CredArr.Password[ i ] 
			CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) );;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
}

Ive tried in these few spots didnt work kept the space or only showed one character in message box
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 23:03

This type of change with the addition of the Trim() function:

Code: Select all

CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) )
...is meant to go in place of this line:

Code: Select all

CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
...not in addition to it.


If you had a line that was working before except the output had a space before it like you described before, then adding Trim() as suggested can only remove the space. It wouldn't do anything else. It's hard to tell what you've done because you show the same or similar lines repeated in the same group of line. Show the code you had before, and show what you did after (this time only trying to implement the Trim() into existing lines, not adding new lines).
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passwfrom .txt

03 Jan 2022, 23:16

Not sure how to make it clearer than this...

This part of the code:

Code: Select all

CredArr := { Email : [], Password : [] }
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred := StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
}
return
...would become this:

Code: Select all

CredArr := { Email : [], Password : [] }
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred := StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( Trim(Cred.1) ), CredArr.Password.Push( Trim(Cred.2) ) ; <<< this line was changed
}
return

Only one line was changed to trim the spaces around a couple of the array elements. No lines were added.
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passw from .txt

04 Jan 2022, 17:55

Ok so this is all the code for wheat I am trying to do with test gui from CivReborn youtube channel help

Code: Select all




#SingleInstance, Force
if not A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"	
SetWorkingDir,%A_ScriptDir%
CoordMode,Mouse,Screen
CoordMode,Pixel,Screen
Gui,2:+AlwaysOnTop
Gui,2:Add,Button,x10 y10 w200 h20 gFind_IconImage,Login
Gui,2:Add,Button,x10 w200 h20 gGui_1,Load / Reload Icon
Gui,2:Add,Text,x10 ,Press Numpad 1 to stop
Gui,2:Show,x1000 y200

return
2GuiClose:
	ExitApp

Find_IconImage:
	Stop:=0
	While(Stop=0)
		{
			;Loop
			
filereadLine, Email, C:\EmailPass.txt,1

CredArr := { Email : [], Password : [] } ; <-- Credential array to store the emails & passwords
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred 	:= StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( LTrim(Cred.1) ), CredArr.Password.Push( LTrim(Cred.2) )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
	
	msgbox 	% "Email " i ": " 		CredArr.Email[ i ]
			. "`nPassword " i ": " 	CredArr.Password[ i ] 
}


			;ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
			ImageSearch, Loc_X, Loc_Y, 0,0, A_ScreenWidth, A_ScreenWidth,C:\IconImage.png
			if(ErrorLevel=2)
				{
				TrayTip,,= 2`nSomething is wrong`n, 2, 0x10
				return
				}
			else if(ErrorLevel=1)
				{
				TrayTip,,`nWaiting for Icon`n, 2, 0x10
				Stop:=0
				return
				}
			else if(ErrorLevel=0)
			
				tx:=Loc_X+(posw//2)
				ty:=Loc_Y+(posh//2)
				MouseMove,Loc_X+(posw//2) ,Loc_Y+(posh//2)
				Click, %tx% %ty%
				TrayTip,,`nFound! Logging in`n, 2, 0x10
				MouseMove, 1130, 480
				Sleep 5
				Click
				Sleep 5
				Click
				Sleep 5
				Send, {Ctrl Down} {a Down}
				Sleep 5
				Send, {Ctrl Up} {a Up}
				Sleep 5
			
				{
					SendInput % CredArr.Email.1
					cnt := 1
				}
				
				Sleep 5
				MouseMove, 1130, 530
				Sleep 5
				Click
				Sleep 5
				Click
				Sleep 5
				Send, {Ctrl Down} {a Down}
				Sleep 5
				Send, {Ctrl Up} {a Up}
				Sleep 5
			
				{
					SendInput % CredArr.Password.1
					cnt := 0
				}
				Sleep 50
				;Send, {Enter 1}
				Sleep 50
			
					return
				}
	

GuiContextMenu:
	Gui,1:Destroy
	return
	
Move_Window:
	Random,new_x,0,A_ScreenWidth-posw
	Random,new_y,0,A_ScreenHeight-posh
	Gui,1:Show,x%New_x% y%new_y%
	return
	
	Gui_1()
	{
		global
		Gui,1:Destroy
		Gui,1:Margin,0,0
		Gui,1:+AlwaysOnTop -caption +Owner2
		Gui,1:Add,Picture,x0 y0 vClip_Picture gMove_Window,C:\IconImage.png
		GuiControlGet,pos,1:pos,Clip_Picture
		Gui,1:Show, AutoSize
	}

Tab::
	Stop:=1
	reload
	


ESC::ExitApp

It isnt working maybe I have something else entered wrong in this code?
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passw from .txt

04 Jan 2022, 18:18

I thought I couldn’t make it more clear that you wouldn’t have more than one version of the same line (the exact same as each other but one version trims spaces), so why do you have both of these two lines in your code? :

Code: Select all

	CredArr.Email.Push( LTrim(Cred.1) ), CredArr.Password.Push( LTrim(Cred.2) )
	CredArr.Email.Push( Cred.1 ), CredArr.Password.Push( Cred.2 )
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passw from .txt

05 Jan 2022, 02:42

Well I tried it with those lines in different spots and wouldn't work. I also tried each line alone in few spots and none will remove spaces I'm new to this and seems like a easy thing to fix but I've tried multiple different Solutions and it hasn't worked. In the text file there is no spaces :( But when i sendinput from the first line of the file it inputs spaces there is spaces it also shows in the message box with spaces

Email1: EmailEmail@Email.com
Passw1: PasswPasswPassw

Code: Select all

filereadLine, Email, C:\EmailPass.txt,1

CredArr := {Email : [],Password : [] } ; <-- Credential array to store the emails & passwords
For i, Row in StrSplit( Email, "`n", "`r" )
{
	Cred := StrSplit( Row, [ ":", " " ] )
	CredArr.Email.Push( LTrim(Cred.1) ), CredArr.Password.Push( LTrim(Cred.2) ) ; <<< this line was changed
	
	MsgBox 	% "Email " i ": " 		CredArr.Email[ i ]
			. "`nPassword " i ": " 	CredArr.Password[ i ]
			
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passw from .txt

05 Jan 2022, 06:28

That’s because your MsgBox has spaces (the ones inside the sets of quotation marks), not because the data contains spaces. If you don’t want spaces in the MsgBox output, remove them. That line would be like this with the output spaces removed:

Code: Select all

	MsgBox 	% "Email" i ":" 		CredArr.Email[ i ]
			. "`nPassword" i ":" 	CredArr.Password[ i ]
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passw from .txt

05 Jan 2022, 08:43

Is it possible to make that msgbox a TrayTip??

Code: Select all

	MsgBox 	% "Email" i ":" 		CredArr.Email[ i ]
			. "`nPassword" i ":" 	CredArr.Password[ i ]
			
I tried this way and it didnt work

Code: Select all

TrayTip,, % "Email" i ":" 		CredArr.Email[ i ]
			. "`nPassword" i ":" 	CredArr.Password[ i ], 2, 0x10
If that can be a trayTip that would be so cool!
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passw from .txt

05 Jan 2022, 09:06

There’s no reason it couldn’t be. Did you try it?
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passw from .txt

06 Jan 2022, 14:39

yes I tried like this it doesn't show me the traytip nothing happens script just continues

Code: Select all

TrayTip,, % "Email" i ":" 		CredArr.Email[ i ]
				. "`nPassword" i ":" 	CredArr.Password[ i ]
				
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Hello i want to read my email and passw from .txt

06 Jan 2022, 15:09

Try running the following as a standalone test script and see if it produces a TrayTip. It does for me.

Code: Select all

i := 1
CredArr_Email := "email@abc.com"
CredArr_Password := "123456"

TrayTip,, % "Email" i ":" 		CredArr_Email
				. "`nPassword" i ":" 	CredArr_Password
Blastoise465
Posts: 58
Joined: 02 Jan 2022, 20:32

Re: Hello i want to read my email and passw from .txt

06 Jan 2022, 15:32

I tried it and it did not work so I tried this to double check and with MsgBox did work :(

Code: Select all

i := 1
CredArr_Email := "email@abc.com"
CredArr_Password := "123456"

MsgBox % "Email" i ":" 		CredArr_Email
				. "`nPassword" i ":" 	CredArr_Password
				
				;Tab::Reload
				

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: joefiesta, leothlon and 108 guests