Jump to content

Only write coords once in a file


Go to solution Solved by Valnurat,

Recommended Posts

Hi.

How can I have the coords from pixelsearch written only once in a file even that the pixel I search for wil be disabled and enabled?

When it is enabled the pixel will be on different position.

Sleep(10000)
FileWrite($file, @CRLF)
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " STARTTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
Local $begin = TimerInit()
Do
 $Count = $Count + 1
 Do
  $POSCoord = PixelSearch( 367, 511, 1190, 666, 0x563E24 )
  If Not @error Then
   FileWrite($file, $POSCoord[0] & ',' & $POSCoord[1] & @CRLF)
   MouseMove($POSCoord[0],$POSCoord[1])
  EndIf
 Until Not @error
    $dif = TimerDiff($begin)
Until $dif >= 1800000
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " ENDTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWrite($file, $Count & @CRLF)
FileClose($file)
 

Btw, I have seen on other post that the code that has been attach have diffent colors. How do I do that?

Yours sincerely

Kenneth.

Link to comment
Share on other sites

Your code says you are searching a LARGE area of the screen.

PixelSearch( 367, 511, 1190, 666, 0x563E24 )

When you do this like this it is obvious you are looking for a change in something. So, logic says then your looking for a change in a control in the area you are searching in. So, I ask again, why can't you hook into a control to see if something has changed?

Link to comment
Share on other sites

Try this

Sleep(10000)
;$file = @ScriptDir & "\test.txt"
FileWrite($file, @CRLF)
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " STARTTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

Local $OldPOSCoord[2], $Count
Local $begin = TimerInit()
Do
    $Count = $Count + 1
    Do
        $POSCoord = PixelSearch( 367, 511, 1190, 666, 0x563E24 )
            If Not @error Then
                IF $POSCoord [0] <> $OldPOSCoord[0] OR $POSCoord [1] <> $OldPOSCoord[1]  Then
                    $OldPOSCoord[0] = $POSCoord[0]
                    $OldPOSCoord[1] = $POSCoord[1]
                    FileWrite($file, $POSCoord[0] & ',' & $POSCoord[1] & @CRLF)
                    MouseMove($POSCoord[0],$POSCoord[1])
                EndIf
            EndIf
    Until Not @error
    $dif = TimerDiff($begin)
Until $dif >= 1800000
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " ENDTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWrite($file, $Count & @CRLF)
FileClose($file)
Link to comment
Share on other sites

  • Solution

 

Try this

Sleep(10000)
;$file = @ScriptDir & "\test.txt"
FileWrite($file, @CRLF)
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " STARTTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

Local $OldPOSCoord[2], $Count
Local $begin = TimerInit()
Do
    $Count = $Count + 1
    Do
        $POSCoord = PixelSearch( 367, 511, 1190, 666, 0x563E24 )
            If Not @error Then
                IF $POSCoord [0] <> $OldPOSCoord[0] OR $POSCoord [1] <> $OldPOSCoord[1]  Then
                    $OldPOSCoord[0] = $POSCoord[0]
                    $OldPOSCoord[1] = $POSCoord[1]
                    FileWrite($file, $POSCoord[0] & ',' & $POSCoord[1] & @CRLF)
                    MouseMove($POSCoord[0],$POSCoord[1])
                EndIf
            EndIf
    Until Not @error
    $dif = TimerDiff($begin)
Until $dif >= 1800000
FileWrite($file, "DATO: " & @MDAY & '-' & @MON & '-' & @YEAR & " ENDTIME: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWrite($file, $Count & @CRLF)
FileClose($file)

 

I haven't tried it yet, but I was thinking that the pointer will be on the same position for about 5 sec, so in these 5 sec the pixelsearch can see the same position. So it will save the position in the file more than once, right?

Yours sincerely

Kenneth.

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