Jump to content

My Script has an Odd Behaviour...


Pera
 Share

Recommended Posts

ok here is my script;

[/autoit]

Global $file = FileOpen("C:\Documents and Settings\user\My Documents\My Downloads\Goodies\chat.log", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
            
Mouseclick("Right", 725, 480, 1)    

$TexttobeRead = FileRead($file)
;MsgBox(0, "Outside the BG", $TexttobeRead, 10)

If StringInStr($TexttobeRead, "entering") Then
    
     ;MsgBox(0, "Inside the BG", "We are Inside the BG", 10)
     Sleep(Random(75000, 90000))
     Send("{LCTRL 2}")
     Send("{g}")
     InsideBG()
     Sleep(Random(3000, 5000))
     DeleteLog() 
 EndIf
 
;MsgBox(0, "Waiting to Enter the BG","", 10)
Sleep(Random(30000, 45000))

Wend

Func DeleteLog()

;MsgBox(0, "BG is Over", "We are out of BG Deleting chat.log", 10)
FileClose($file)
$file = FileOpen("C:\Documents and Settings\user\My Documents\My Downloads\Goodies\chat.log", 2)
FileClose($file)
$file = FileOpen("C:\Documents and Settings\user\My Documents\My Downloads\Goodies\chat.log", 0)
EndFunc

Func InsideBG()

Do 

Send("{TAB}")
Sleep(random(2000, 4000))
Send("{TAB}")
Sleep(random(2000, 4000))
Send("{TAB}")
Sleep(random(2000, 4000))
Send("{TAB}")
Sleep(random(2000, 4000))

$InsideBGCheck = FileRead($file)
;MsgBox(0, "Inside BG Function", $InsideBGCheck, 10)

Sleep(Random(3000, 6000))

Send("{LCTRL 2}")
Send("{g}")

Until StringInStr($InsideBGCheck, "close")
Sleep(Random(130000, 150000))
EndFunc 

[autoit]

What is really odd with the behaviour is that sometimes after like 100+ runs even though the chat.log file contains word "close" it doesn't delete the .log. Instead it keeps copying the existing text over and over in the .log file. For example if the chat .log looked like this;

entering

blah blah lah

close

instead of deleting the .log file it keeps writing

entering

blah blah lah

close

entering

blah blah lah

close

entering

blah blah lah

close

...

I would appreciate any help.

Thanks!

Edited by Pera
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...