ofLight Posted February 1, 2007 Share Posted February 1, 2007 I have tried Larrys old Script and it is 100% accurate and reliable, but i am trying to move over to the new PixelCheckSum.http://www.autoitscript.com/forum/index.ph...xelRectFromFileThis is my current script, it Works, but only Sometimes... and only if i select a VERY unique pixel to look for. I need a way to make it More reliable, and I need to be able to select a starting pixel that is NOT unique.Any Suggestions would be greatly Appreciated, TYexpandcollapse popupHotKeySet("`","_find") HotKeySet("~","record") HotKeySet('{esc}', '_Exit') Global $msg = "Press Shift+tilde to Record " & @LF & _ "Press tilde to Find " & @LF & _ "info saved in Pixel.ini" Global $xy,$currentpixel ;If $pixel = -1 Or $chksum = -1 Then ; MsgBox(4096,"Error","Could not read INI") ; Exit ;EndIf While 1 $xy = MouseGetPos() $currentpixel = PixelGetColor($xy[0],$xy[1]) ToolTip("Pixel color = " & $currentpixel & @LF & $msg) Sleep(100) WEnd Func record() IniWrite(".\Pixel.ini","Main","PixelColor",$currentpixel) Local $chksum = PixelChecksum($xy[0]-5, $xy[1]-5, $xy[0]+5, $xy[1]+5) IniWrite(".\Pixel.ini","Main","PixelCheckSum",$chksum) MsgBox(4096,"","Pixel Area Recorded." & @LF & @LF & "See INI file for details.", 2) ;Exit EndFunc Func _find() Local $pixel = Int(IniRead(".\Pixel.ini","Main","PixelColor","-1")) Local $chksum = Int(IniRead(".\Pixel.ini","Main","PixelCheckSum","-1")) $w = 1 $x = 5 $y = 5 $ypixel = @DesktopHeight - 5 $xpixel = @DesktopWidth - 5 While $w = 1 $xy = PixelSearch($x,$y,$xpixel,$ypixel,$pixel) If $w = 3 Then Exit EndIf If @error Then $y = $ypixel + 1 $ypixel = (@DesktopHeight - 1) $x = 0 _cont() ;$w = 2 ElseIf $chksum = PixelCheckSum($xy[0]-5, $xy[1]-5, $xy[0]+5, $xy[1]+5) Then $w = 3 MouseMove($xy[0],$xy[1], 30) ToolTip("Found Checksum") $pos = MouseGetPos() MouseMove( $pos[0], $pos[1] -10, 20) ;Top MouseMove( $pos[0] +10, $pos[1], 20) ;Right MouseMove( $pos[0], $pos[1] +10, 20) ;Bottom MouseMove( $pos[0] -10, $pos[1], 20) ;Left ;Exit Else MsgBox(4096, 'Error', 'Not @Error, and cant find checksum', 5) $w = 2 EndIf WEnd EndFunc Func _cont() MsgBox(4096,"@Error","Could not find Checksum" & @LF & ' looking again in 3sec', 3) _find() EndFunc Func _Exit() ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ') Sleep(500) Exit EndFunc There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 1, 2007 Moderators Share Posted February 1, 2007 I wrote this the other day:http://www.autoitscript.com/forum/index.ph...st&p=300569 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ofLight Posted February 1, 2007 Author Share Posted February 1, 2007 Thank You for the Post Smoke. Ive Looked at Your Script and Mine, and i think i see what the problem with mine is. The reason its not reliable is Because it only finds the First Instance of the Correct pixel, and then checks the Checksum. When this doesnt match the script fails. So now I need to figure out howto tell my script to Skipover/Ignore a location that Matches the Pixel but not the Checksum. Any Ideas guys?? There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 1, 2007 Moderators Share Posted February 1, 2007 (edited) Thank You for the Post Smoke. Ive Looked at Your Script and Mine, and i think i see what the problem with mine is. The reason its not reliable is Because it only finds the First Instance of the Correct pixel, and then checks the Checksum. When this doesnt match the script fails.So now I need to figure out howto tell my script to Skipover/Ignore a location that Matches the Pixel but not the Checksum.Any Ideas guys??Yeah... Use the one I posted. Edited February 1, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ofLight Posted February 1, 2007 Author Share Posted February 1, 2007 All Right got it Working. Thanks for the Help Guys. Just in case anyone wants to see, this is the result. Seems to work every time, as long as you specify an appropriate size for the checksum based on how complex or simple a Word or character u are looking for. expandcollapse popupHotKeySet("`","_find") HotKeySet("~","record") HotKeySet('{esc}', '_Exit') Global $msg = "Press Shift+tilde to Record " & @LF & _ "Press tilde to Find " & @LF & _ "info saved in Pixel.ini" Global $xy,$currentpixel ;If $pixel = -1 Or $chksum = -1 Then ; MsgBox(4096,"Error","Could not read INI") ; Exit ;EndIf While 1 $xy = MouseGetPos() $currentpixel = PixelGetColor($xy[0],$xy[1]) ToolTip("Pixel color = " & $currentpixel & @LF & $msg) Sleep(100) WEnd Func record() IniWrite(".\Pixel.ini","Main","PixelColor",$currentpixel) Local $chksum = PixelChecksum($xy[0]-15, $xy[1]-15, $xy[0]+15, $xy[1]+15) IniWrite(".\Pixel.ini","Main","PixelCheckSum",$chksum) MsgBox(4096,"","Pixel Area Recorded." & @LF & @LF & "See INI file for details.", 2) ;Exit EndFunc Func _find() Local $pixel = Int(IniRead(".\Pixel.ini","Main","PixelColor","-1")) Local $chksum = Int(IniRead(".\Pixel.ini","Main","PixelCheckSum","-1")) $w = 1 $x = 5 $y = 5 $ypixel = @DesktopHeight - 5 $xpixel = @DesktopWidth - 5 $sv = 0 While $w = 1 $xy = PixelSearch($x,$y,$xpixel,$ypixel,$pixel, $sv) ;MouseMove($xy[0],$xy[1], 30) If $w = 3 Then Exit EndIf If @error And $ypixel = (@DesktopHeight - 1)Then SetError(1) Return 0 ElseIf @error Then $y = $ypixel + 1 $ypixel = (@DesktopHeight - 1) $x = 0 ;_cont() ElseIf $chksum = PixelCheckSum($xy[0]-15, $xy[1]-15, $xy[0]+15, $xy[1]+15) Then $w = 3 MouseMove($xy[0],$xy[1], 30) ToolTip("Found Checksum") $pos = MouseGetPos() MouseMove( $pos[0], $pos[1] -10, 20) ;Top MouseMove( $pos[0] +10, $pos[1], 20) ;Right MouseMove( $pos[0], $pos[1] +10, 20) ;Bottom MouseMove( $pos[0] -10, $pos[1], 20) ;Left ;Exit Else $y = $xy[1] $ypixel = $y $x = $xy[0] + 1 ;$sv = $sv+1 ;Sleep(50) ;MsgBox(4096, 'Error', 'Not @Error, and cant find checksum'&@CRLF&$sv, 2) ;$w = 2 EndIf WEnd EndFunc Func _cont() MsgBox(4096,"@Error","Could not find Checksum" & @LF & ' looking again in 2sec', 2) _find() EndFunc Func _Exit() ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ') Sleep(500) Exit EndFunc There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 1, 2007 Moderators Share Posted February 1, 2007 (edited) You're doing this for an OCR?Anyway... on your code, you could definitely run into a recursion issue there.Edit:Never mind, I didn't notice (hard to see) that you commented out _cont(). Edited February 1, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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