Jump to content
Sign in to follow this  
Valnurat

Only write coords once in a file

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?

Share this post


Link to post
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?

Share this post


Link to post
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)

Share this post


Link to post
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)

 

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?

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...