Jump to content

Help With Logging


Recommended Posts

Ok I Want It To Log Everytime It Does This Line In The Code

Do 
       $PixMine = PixelGetcolor (401,278)
       $PixMine2 = PixelGetColor (399,326)
       $PixWest = PixelGetColor (557,215)
       $PixWest2 = PixelGetColor (559,243)
       If $PixMine = 13693136 Then
           Mouseclick("Left", 401, 278, 1, 30)
           Sleep($Click)
       Endif

So I Thought Something Like

$Log=1 (At The Start Of The Script)

Then Everytime It Clicks

$Log= $Log+1 (Then Log This Number In A File)

Any Idea How To Do This?

Link to comment
Share on other sites

To create a log, you just need to open a file and then write to it. For example:

$log1=FileOpen("log.txt", 1)

FileWriteLine($log1, "Script started at " & @HOUR & ":" @MIN & " at " & @MON & "/" & @MDAY & "/" & @YEAR @CR)

FileClose($log1)

Do

      $PixMine = PixelGetcolor (401,278)

      $PixMine2 = PixelGetColor (399,326)

      $PixWest = PixelGetColor (557,215)

      $PixWest2 = PixelGetColor (559,243)

      If $PixMine = 13693136 Then

          Mouseclick("Left", 401, 278, 1, 30)

          Sleep($Click)

      Endif

$log2=FileOpen("log.txt", 1)

FileWriteLine($log2, "Script stopped at " & @HOUR & ":" @MIN & " at " & @MON & "/" & @MDAY & "/" & @YEAR @CR)

FileClose($log2)

The script will output: "Script started at 19:20 on 03/17/04" in the log.txt file when it starts (time and date change, of course!) and will also note when it stops.

Edited by SerialKiller
Link to comment
Share on other sites

To create a log, you just need to open a file and then write to it. For example:

The script will output: "Script started at 19:20 on 03/17/04" in the log.txt file when it starts (time and date change, of course!) and will also note when it stops.

How about ...

$log1="log.txt" ; place this near biginning of script

Do

$begin = TimerStart()

$TimeStart = "Script started at " & @HOUR & ":" @MIN & " at " & @MON & "/" & @MDAY & "/" & @YEAR

$PixMine = PixelGetcolor (401,278)

$PixMine2 = PixelGetColor (399,326)

$PixWest = PixelGetColor (557,215)

$PixWest2 = PixelGetColor (559,243)

If $PixMine = 13693136 Then

Mouseclick("Left", 401, 278, 1, 30)

Sleep($Click)

Endif

$dif = TimerStop($begin)

FileWrite($log1, $TimeStart & " - Duration = " & $dif & " milliseconds" & @CRLF)

$dif = 0

; This only writes once per iteration

; You didn't say what the frequency of repeat is. If is very quick and many many repeats, then you should iether use a file handle variable instead of a file name (as I did above, or concantenate the log results for 20 or so iterations and write out all 20 (or so) at once.

;A concantenation example:

Do

$count = $count + 1

$begin = TimerStart()

$TimeStart = "Script started at " & @HOUR & ":" @MIN & " at " & @MON & "/" & @MDAY & "/" & @YEAR

$PixMine = PixelGetcolor (401,278)

$PixMine2 = PixelGetColor (399,326)

$PixWest = PixelGetColor (557,215)

$PixWest2 = PixelGetColor (559,243)

If $PixMine = 13693136 Then

Mouseclick("Left", 401, 278, 1, 30)

Sleep($Click)

Endif

$dif = TimerStop($begin)

if $count < 20 then

$LogVar = $LogVar & $TimeStart & " - Duration = " & $dif & " milliseconds" & @CRLF

else

FileWrite($log1, $LogVar)

$LogVar = ""

$count = 0

endif

; The result in the file will be...

Line after line of start times and durations.

;

With this and other folks examples and some thoght I'm sure you come up with a method best suited for you.

Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

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