Jump to content

Searching a File for Keywords


XxXFaNtA
 Share

Recommended Posts

Hi everybody :geek:

I'm new to AutoIt and i've a little question.

I tried to open a File and then search for some Keywords and then getting the Text that is after this Keywords.

Example:

textextext = text

Hello=Fanta.exe

textextext = text

moretext = text

Hello=Needs.exe

text= text

othercrap = text

Hello = Help.exe

The script should search the Keyword Hello and then saving the Text Fanta.exe, Needs.exe, Help.exe ..

Can somebody Help me? :o

I did once somethink similar to that (tried making a small chatbot but it has some odd bugs...)..

I tried somethink like this:

#include <file.au3>

$file = FileOpen("C:\myfile.ini", 0)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

...

But somehow if i checked $file it was = 1 :huggles:

It would be nice if someone could give me a hint or help me ;) (like what i have to look for)

Thx :sorcerer:

Link to comment
Share on other sites

Check out the help file for IniRead. That should do what you're looking for.

Hi everybody :geek:

I'm new to AutoIt and i've a little question.

I tried to open a File and then search for some Keywords and then getting the Text that is after this Keywords.

Example:

textextext = text

Hello=Fanta.exe

textextext = text

moretext = text

Hello=Needs.exe

text= text

othercrap = text

Hello = Help.exe

The script should search the Keyword Hello and then saving the Text Fanta.exe, Needs.exe, Help.exe ..

Can somebody Help me? :o

I did once somethink similar to that (tried making a small chatbot but it has some odd bugs...)..

I tried somethink like this:

#include <file.au3>

$file = FileOpen("C:\myfile.ini", 0)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

...

But somehow if i checked $file it was = 1 :huggles:

It would be nice if someone could give me a hint or help me ;) (like what i have to look for)

Thx :sorcerer:

Link to comment
Share on other sites

Do you mean like this? Maybe not exactly what your trying to do but you can modify it I'm sure

$File = FileOpen ("MyTextfile.txt",0)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
    
    $line = FileReadLine ( $File)
    if @error = -1 then ExitLoop
    If Stringinstr ($line, "MyString") then FileWriteLine ("MyNewfile.txt", $Line)
    WEnd
    FileClose ($File)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...