Valnurat Posted August 6, 2014 Share Posted August 6, 2014 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 More sharing options...
Bert Posted August 6, 2014 Share Posted August 6, 2014 That is a LARGE area to pixel search in. Is there some reason why you can't simply hook into a control? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valnurat Posted August 6, 2014 Author Share Posted August 6, 2014 What do you mean by that? Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
Bert Posted August 7, 2014 Share Posted August 7, 2014 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? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valnurat Posted August 7, 2014 Author Share Posted August 7, 2014 Well, it's not my call. My company want it this way. It's a measuring instrument they want me to find the position of a pointer. I can't take control of that pointer, because it's a measuring application. Bert 1 Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
Geir1983 Posted August 7, 2014 Share Posted August 7, 2014 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 More sharing options...
Solution Valnurat Posted August 7, 2014 Author Solution Share Posted August 7, 2014 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 More sharing options...
Valnurat Posted August 7, 2014 Author Share Posted August 7, 2014 (edited) I see what you have done. I will check it when I come to work. Edited August 7, 2014 by Valnurat Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now