Jump to content
Sign in to follow this  
Arclite86

Read from notepad

Recommended Posts

Arclite86

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

Share this post


Link to post
Share on other sites
FireFox

Hi,

115 posts and you didn't take a look at the helpfile? come on...

>> ControlGetText

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Malkey

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

Share this post


Link to post
Share on other sites
FireFox

You're right, better do it for him.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Arclite86

 

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

Share this post


Link to post
Share on other sites
FireFox

notepad.exe C:\Users\name pc\Desktop\autoit\project


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Arclite86
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

Share this post


Link to post
Share on other sites
FireFox

lol. I'm OFF this topic.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Valiante

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.

Share this post


Link to post
Share on other sites
TrickyDeath

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. :D

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)

Share this post


Link to post
Share on other sites
TrickyDeath

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)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×