There are only 2 function's.
_pixel_getpattern($pos1, $pos2, $len, [opt]$gui, [opt]ScreenMode)
_pixel_ratio($pattern, $pattern2, [opt]$ratio_level)
With _pixel_ratio you have to have 2 patterns to compare. and ratio level is 0-4
if it is 0 by default then it will return the result in pixel's that are the same in $pattern and $pattern2.
if you have ratio level higher than 0 then it will return a array. Look at example, You'll understand
UDF:
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Func _pixel_getpattern($pos1, $pos2, $len, $gui = "", $screen = 0) if $len > 50 Then ConsoleWriteError("ERROR: Parameter lenght over limit ( 50 )" & @CRLF) SetError(500) Exit(500) EndIf if $len < 0 Then ConsoleWriteError("ERROR: Parameter lenght under limit ( 0 )" & @CRLF) SetError(505) Exit(505) EndIf if $pos1 < 0 or $pos2 < 0 then ConsoleWriteError("ERROR: Location cannot be under 0" & @CRLF) SetError(501) Exit(501) EndIf if $screen > 2 or $screen < 0 Then ConsoleWriteError("ERROR: Screen mode cannot be over 2 or smaller than 0!" & @CRLF) SetError(504) Exit(504) EndIf Opt("PixelCoordMode", $screen) Local $color[9999999] $i = 0 $x = $pos1 - $len $y = $pos2 - $len $n = 0 Do $n = $n + 1 $color[$n] = PixelGetColor($x, $y, $gui) $y = $y + 1 if $y = $pos2 + $len Then $y = $pos2 - $len $i = $i + 1 $x = $x + 1 EndIf Until $i = $len*2 or $i > $len*2 $color[0] = $n Return $color EndFunc ;==>Example1 Func _pixel_ratio($pattern, $pattern2, $confirm = 0) if $confirm <> 0 then $confirm = $confirm if $confirm > 10 Then ConsoleWriteError("ERROR: Too high confirm level! ( 10 max )" & @CRLF) SetError(502) Exit(502) EndIf Local $result[10] $i = 0 $n = 0 Do $n = $n + 1 if $pattern[$n] = $pattern2[$n] then $i = $i + 1 Until $n = $pattern[0] or $n > $patter[0] $confirm_level = 0 if Number(($i/$pattern[0])*100) > 70 then $confirm_level = 3 if Number(($i/$pattern[0])*100) > 90 then $confirm_level = 4 if Number(($i/$pattern[0])*100) < 50 then $confirm_level = 2 if Number(($i/$pattern[0])*100) < 30 then $confirm_level = 1 $result[1] = $i if $confirm > 1 Then $result[2] = $confirm_level if $confirm > 2 Then $result[3] = Number(($i/$pattern[0])*100) if $confirm > 3 Then $result[4] = $i & "/" & $pattern[0] & " Pixel's" if $confirm = 0 Then $result = $i Return $result EndFunc
Example:
#include <pattern.au3> $gui = GUICreate("Advanced Example", 124, 168, 900, 600) GUISetState() $pattern = _pixel_getpattern(50, 50, 20) $bar = GUICtrlCreatePic("bar.jpg", 100, 100, 10, 0) $status = GUICtrlCreateLabel("", 0, 10, 90, 100) while 1 $pos = MouseGetPos() $pattern2 = _pixel_getpattern($pos[0], $pos[1], 20) $ratio = _pixel_ratio($pattern, $pattern2, 10) GUICtrlSetPos($bar, 100, 100-$ratio[3], 10, $ratio[3]) GUICtrlSetData($status, "Correct: " & $ratio[1] & @CRLF & "Confirm Level: " & $ratio[2] & @CRLF & $ratio[3] & " %" & @CRLF & $ratio[4]) Sleep(1) WEnd
Update 16. Sept
* Added Safety Protocols incase of Heavy CPU or RAM Consuption.
TESTED ON XP! MAY NOT WORK ON WIN 7 OR VISTA!
Edited by Zibit, 16 September 2010 - 08:41 AM.






