Jump to content

Read 1 word from a couple of lines?


Recommended Posts

Im totally new with AutoIT so forgive my question if its to easy :P

Im trying to read a specifiek word on some active page. If the word is there then it must return a 1.

I have tried it with a simple notepad text file but I can only read the whole page instead of 1 word.

Example:

winwaitactive("testje - Notepad")

$text = WinGetText("testje -", "hallo")

MsgBox(0, "Text read was:", $text)

This script will give me all the words in the testje.txt but I only need the word hallo.!

What am I doing wrong here?

Link to comment
Share on other sites

Hi,

$file = FileOpen("test.txt", 0)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
$chars = FileRead($file)
FileClose($file)
MsgBox(0, "", $chars)
If StringInStr($chars, "Hello") <> 0 Then MsgBox(0,"info", "found")

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

sorry I do not get any errors. Works as designed. Can you post the error message, please.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Instead of this:

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

$chars = FileRead($file)
FileClose($file)
MsgBox(0, "", $chars)
If StringInStr($chars, "hallo") <> 0 Then MsgBox(0,"info", "found")oÝ÷ Ø¢é]²)©&Þjëh×6$chars = FileRead("testje.txt")
MsgBox(0, "", $chars)
If StringInStr($chars, "hallo") Then MsgBox(0,"info", "found")oÝ÷ ØêÞ½éÚºÚ"µÍYÝ[Ò[Ý[TXY
    ][ÝÝÝK   ][ÝÊK ÌÎNÚ[ÉÌÎNÊH[ÙÐÞ
    ][ÝÚ[É][ÝË ][ÝÙÝ[   ][ÝÊ

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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