Jump to content

Recommended Posts

Posted

Hi there,

I am trying to get the text within a .log file that is being updated by the game as events progress. I used WinGetText;

[/autoit]
$TexttobeRead = WinGetText("Chat.log -", "")
[autoit]

However, as the chat.log updates it doesn't actually update in the open document. Is there a way to capture the text within chat.log in real time? I than would like to use StringInStr to compare the text with a substring.

Thanks in advance

Posted

You could create a loop that would continuously check

I did the loop with WinGetText, however when I have the "chat.log" open, whatever is in the open file is actually being captured by WinGetText. In the meantime the game is still updating chat.log on the background but the updates doesn't display in the open file. I hope it makes sense...

Posted

Oh, I see. Have you tried using a "read string"-type command?

EDIT: I don't know if I'm giving the correct term...

I am not sure if I know any string commands that will get the text within a file?

Posted

I am not sure if I know any string commands that will get the text within a file?

I really appreciate for even the smallest tip on this... I have been working on it forever heh...

  • Moderators
Posted

I really appreciate for even the smallest tip on this... I have been working on it forever heh...

FileRead()?

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.

Posted

I'm not sure whether you want to read Window Text or text file...

Try this it should be fine if it's log and appending to the end...

#include <File.au3>

Dim $aChatlog, $TotalLine
$chatlog = @ScriptDir & "\chat.log"
$TimeStamp = FileGetTime($chatlog, 0, 1)
_FileReadToArray($chatlog, $aChatlog)
$TotalLine = $aChatlog[0]
While 1
    If FileGetTime($chatlog, 0, 1) <> $TimeStamp Then
        $TimeStamp = FileGetTime($chatlog, 0, 1)
        _FileReadToArray($chatlog, $aChatlog)
        If IsArray($aChatlog) Then
            $newLines = ""
            For $i = $TotalLine To $aChatlog[0]
                $newLines &= $aChatlog[$i] & @CRLF
            Next
        EndIf
        MsgBox (0,"Changed","New line(s) : " & @CRLF & $newLines)
    EndIf
    Sleep(1000)
WEnd
Posted (edited)

Hey thanks fo rthe script. I tried it and it gives an error in line 7...

Edited by Pera
Posted

Hey thanks fo rthe script. I tried it and it gives an error in line 7...

I think you are having a problem reading a file.

change this section and try.

#include <File.au3>

Dim $aChatlog, $TotalLine
$chatlog = @ScriptDir & "\chat.log"
$TimeStamp = FileGetTime($chatlog, 0, 1)
If Not _FileReadToArray($chatlog, $aChatlog) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
$TotalLine = $aChatlog[0]
Posted

I think you are having a problem reading a file.

change this section and try.

#include <File.au3>

Dim $aChatlog, $TotalLine
$chatlog = @ScriptDir & "\chat.log"
$TimeStamp = FileGetTime($chatlog, 0, 1)
If Not _FileReadToArray($chatlog, $aChatlog) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
$TotalLine = $aChatlog[0]
I am getting message "error reading log to array: 1". Sorry I am causing a lotof trouble...
  • Moderators
Posted (edited)

You don't have the right file location more than likely. All of the options provided will work, but you have to replace:

$chatlog = "Change This to the actual location, not just "chat.log""oÝ÷ ØGbµ§¶¬jëh×6Global $hChatLog = 'chat.log', $sString = ''
If Not FileExists($hChatLog) Then
    MsgBox(16, 'Error', 'File Does not exist here')
    Exit -1
EndIf
$sString = FileRead($hChatLog)
MsgBox(64, 'Info', 'File Contains: ' & @CR & @CR & $sString)
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.

Posted

You don't have the right file location more than likely. All of the options provided will work, but you have to replace:

$chatlog = "Change This to the actual location, not just "chat.log""oÝ÷ ØGbµ§¶¬jëh×6Global $hChatLog = 'chat.log', $sString = ''
If Not FileExists($hChatLog) Then
    MsgBox(16, 'Error', 'File Does not exist here')
    Exit -1
EndIf
$sString = FileRead($hChatLog)
MsgBox(64, 'Info', 'File Contains: ' & @CR & @CR & $sString)
Guys I really appreciate all of your help. I finally figured this out. My file location was incorrect. Well it was correct but it was under a different user account than what I used :)

Thanks a lot once again!

  • 3 weeks later...

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
  • Recently Browsing   0 members

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