Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Misc.au3>
- #include <Array.au3>
- HotKeySet("{F6}", "_Toggle")
- HotKeySet("{F7}", "_Exit")
- ToolTip("Activate the window and press F6 when done", 0, 0)
- $active = False
- Do
- Sleep(10)
- Until $active
- $active = False
- $found = False
- $hwnd = WinGetHandle("[Active]")
- $s = _GetCoords("Upper left")
- $e = _GetCoords("Lower rigt")
- $num = 1
- $num2 = 1
- Func _GetCoords($t)
- ToolTip("Press Mouse button to define '"&$t&"'", 0, 0)
- Do
- Sleep(10)
- Until _IsPressed(1)
- Do
- Sleep(10)
- Until Not _IsPressed(1)
- ToolTip("")
- Return MouseGetPos()
- EndFunc
- While True
- If $active Then
- If $arr = -1 Then
- ConsoleWrite("new image" & @crlf)
- $arr = _GetArr($s, $e)
- Else
- $found = False
- For $y = $s[1] To $e[1]
- For $x = $s[0] To $e[0]
- $arr[$x-$s[0]][$y-$s[1]] = _Color($x, $y, $arr[$x-$s[0]][$y-$s[1]])
- Next
- Next
- If $found Then
- Sleep(3000)
- $arr = -1
- EndIf
- EndIf
- Else
- Sleep(500)
- EndIf
- ConsoleWrite($num2 & @crlf)
- $num2 += 1
- WEnd
- Func _Toggle()
- _Set(Not $active)
- EndFunc
- Func _Set($state)
- $active = $state
- ToolTip("active="&$active, 0, 0)
- If $active Then Global $arr = -1
- EndFunc
- Func _GetArr($s, $e)
- Local $array[$e[0]-$s[0]+1][$e[1]-$s[1]+1]
- For $y = $s[1] To $e[1]
- For $x = $s[0] To $e[0]
- $array[$x-$s[0]][$y-$s[1]] = -1
- Next
- Next
- Return $array
- EndFunc
- Func _Color($x, $y, $c, $h = $hwnd)
- Local $col = PixelGetColor($x, $y, $h)
- If $c <> $col And $c <> -1 Then _Trigger()
- Return $col
- EndFunc
- Func _Trigger()
- If $found = True Then Return
- ToolTip("Found! " & $num, 0, 0)
- MouseClick("")
- $num += 1
- $found = True
- EndFunc
- Func _Exit()
- Exit
- EndFunc
- Func _ArrayCompare($1, $2, $start = 1)
- ;If UBound($1) <> UBound($2) Return False
- For $i = $start To UBound($1)
- If $1[$i] <> $2[$i] Then Return False
- Next
- Return True
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement