Arclite86 Posted March 5, 2014 Share Posted March 5, 2014 I want to read from a notepad line for example if this was a notepas and I want get username6 and password6 how can I do that? username1 | password1 username2 | password2 username3 | password3 username4 | password4 username5 | password5 username6 | password6 username7 | password7 username8 | password8 Link to comment Share on other sites More sharing options...
FireFox Posted March 5, 2014 Share Posted March 5, 2014 Hi, 115 posts and you didn't take a look at the helpfile? come on... >> ControlGetText Br, FireFox. Link to comment Share on other sites More sharing options...
Malkey Posted March 5, 2014 Share Posted March 5, 2014 An example: If WinExists("[Class:Notepad]", "") Then Local $Text = ControlGetText("[Class:Notepad]", "", "Edit1") Local $iLineNum = 6 Local $username6 = "username6" Local $sLine = StringRegExpReplace($Text, "(\V+\v+){" & ($iLineNum - 1) & "}(\V+)(?s).+$", "\2") Local $aLine = StringSplit($sLine, " | ", 3) MsgBox(0, "Results", 'Given Line "' & $iLineNum & '"; Gets ' & 'User Name: "' & $aLine[0] & '"; Password: "' & $aLine[1] & '"' & @LF & _ " Or" & @LF & _ 'Given User Name: "' & $username6 & '"; Gets Password: "' & StringRegExpReplace($Text, "(?s)(?:.*)" & $username6 & "\h*\|\h*(\V+).+$", "\1") & '"' & @LF) Else MsgBox(0, "Error", "Notepad does not exist") EndIf Link to comment Share on other sites More sharing options...
FireFox Posted March 5, 2014 Share Posted March 5, 2014 You're right, better do it for him. Link to comment Share on other sites More sharing options...
Arclite86 Posted March 6, 2014 Author Share Posted March 6, 2014 An example: If WinExists("[Class:Notepad]", "") Then Local $Text = ControlGetText("[Class:Notepad]", "", "Edit1") Local $iLineNum = 6 Local $username6 = "username6" Local $sLine = StringRegExpReplace($Text, "(\V+\v+){" & ($iLineNum - 1) & "}(\V+)(?s).+$", "\2") Local $aLine = StringSplit($sLine, " | ", 3) MsgBox(0, "Results", 'Given Line "' & $iLineNum & '"; Gets ' & 'User Name: "' & $aLine[0] & '"; Password: "' & $aLine[1] & '"' & @LF & _ " Or" & @LF & _ 'Given User Name: "' & $username6 & '"; Gets Password: "' & StringRegExpReplace($Text, "(?s)(?:.*)" & $username6 & "\h*\|\h*(\V+).+$", "\1") & '"' & @LF) Else MsgBox(0, "Error", "Notepad does not exist") EndIf so how do open the notepad file, for example: this is the location: C:Usersname pcDesktopautoitproject Link to comment Share on other sites More sharing options...
FireFox Posted March 6, 2014 Share Posted March 6, 2014 notepad.exe C:\Users\name pc\Desktop\autoit\project Link to comment Share on other sites More sharing options...
Arclite86 Posted March 6, 2014 Author Share Posted March 6, 2014 notepad.exe C:\Users\name pc\Desktop\autoit\project like this?: If WinExists("[Class:notepad.exe C:\Users\name pc\Desktop\autoit\project]", "") Then Local $Text = ControlGetText("[Class:Notepad]", "", "Edit1") Local $iLineNum = 6 Local $username6 = "username6" Local $sLine = StringRegExpReplace($Text, "(\V+\v+){" & ($iLineNum - 1) & "}(\V+)(?s).+$", "\2") Local $aLine = StringSplit($sLine, " | ", 3) MsgBox(0, "Results", 'Given Line "' & $iLineNum & '"; Gets ' & 'User Name: "' & $aLine[0] & '"; Password: "' & $aLine[1] & '"' & @LF & _ " Or" & @LF & _ 'Given User Name: "' & $username6 & '"; Gets Password: "' & StringRegExpReplace($Text, "(?s)(?:.*)" & $username6 & "\h*\|\h*(\V+).+$", "\1") & '"' & @LF) Else MsgBox(0, "Error", "Notepad does not exist") EndIf Link to comment Share on other sites More sharing options...
FireFox Posted March 6, 2014 Share Posted March 6, 2014 (edited) lol. I'm OFF this topic. Edited March 6, 2014 by FireFox Link to comment Share on other sites More sharing options...
Valiante Posted March 6, 2014 Share Posted March 6, 2014 Hello Arclite, It sounds like you want to read from a text file, not from Notepad itself. In which case, you don't need to open Notepad, or refer to any windows. Instead, have a look at FileReadLine. Once you have a grip on that, check out StringSplit or even _FileReadToArray in order to achieve what you're trying to do. I could write the function for you, but it would be better if you studied the help file and learned how to use this tool for yourself. Best of luck, Val. Link to comment Share on other sites More sharing options...
TrickyDeath Posted April 7, 2014 Share Posted April 7, 2014 Sry for everyone and sry for the original topic maker (Arclite86), but i do not wanted to make a new topic for my question, cause it is similar for this. My question is, how do i can get how many lines a file have? I can real lines with FileReadLine it is no problem, but i dont wana get that data. For this function, i need only the number of lines in the file. I was searching in help file, but i could not find the solution. Probably i am just lame, and approach it from wrong direction. I tried to put it in a loop... but after i made the loop i mess up it with wrong order. So i get back nothing, just errors Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
TrickyDeath Posted April 7, 2014 Share Posted April 7, 2014 Ahh forget... I was the lame. Found my solution in another topic. _FileCountLines probably what i need. (somehow i did not saw this order in help list) Lame Tricky Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) 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