Advertisement
nO_OnE_910

Untitled

Sep 4th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.89 KB | None | 0 0
  1. #include <Misc.au3>
  2. #include <Array.au3>
  3. HotKeySet("{F6}", "_Toggle")
  4. HotKeySet("{F7}", "_Exit")
  5. ToolTip("Activate the window and press F6 when done", 0, 0)
  6. $active = False
  7. Do
  8.    Sleep(10)
  9. Until $active
  10. $active = False
  11. $found = False
  12. $hwnd = WinGetHandle("[Active]")
  13. $s = _GetCoords("Upper left")
  14. $e = _GetCoords("Lower rigt")
  15. $num = 1
  16. $num2 = 1
  17. Func _GetCoords($t)
  18.    ToolTip("Press Mouse button to define '"&$t&"'", 0, 0)
  19.    Do
  20.       Sleep(10)
  21.    Until _IsPressed(1)
  22.    Do
  23.       Sleep(10)
  24.    Until Not _IsPressed(1)
  25.    ToolTip("")
  26.    Return MouseGetPos()
  27. EndFunc
  28. While True
  29.    If $active Then
  30.       If $arr = -1 Then
  31.          ConsoleWrite("new image" & @crlf)
  32.          $arr = _GetArr($s, $e)
  33.       Else
  34.          $found = False
  35.          For $y = $s[1] To $e[1]
  36.             For $x = $s[0] To $e[0]
  37.                $arr[$x-$s[0]][$y-$s[1]] = _Color($x, $y, $arr[$x-$s[0]][$y-$s[1]])
  38.             Next
  39.          Next
  40.          If $found Then
  41.             Sleep(3000)
  42.             $arr = -1
  43.          EndIf
  44.       EndIf
  45.    Else
  46.       Sleep(500)
  47.    EndIf
  48.    ConsoleWrite($num2 & @crlf)
  49.    $num2 += 1
  50. WEnd
  51. Func _Toggle()
  52.    _Set(Not $active)
  53. EndFunc
  54. Func _Set($state)
  55.    $active = $state
  56.    ToolTip("active="&$active, 0, 0)
  57.    If $active Then Global $arr = -1
  58. EndFunc
  59. Func _GetArr($s, $e)
  60.    Local $array[$e[0]-$s[0]+1][$e[1]-$s[1]+1]
  61.    For $y = $s[1] To $e[1]
  62.       For $x = $s[0] To $e[0]
  63.          $array[$x-$s[0]][$y-$s[1]] = -1
  64.       Next
  65.    Next
  66.    Return $array
  67. EndFunc
  68. Func _Color($x, $y, $c, $h = $hwnd)
  69.    Local $col = PixelGetColor($x, $y, $h)
  70.    If $c <> $col And $c <> -1 Then _Trigger()
  71.    Return $col
  72. EndFunc
  73. Func _Trigger()
  74.    If $found = True Then Return
  75.    ToolTip("Found! " & $num, 0, 0)
  76.    MouseClick("")
  77.    $num += 1
  78.    $found = True
  79. EndFunc
  80. Func _Exit()
  81.    Exit
  82. EndFunc
  83. Func _ArrayCompare($1, $2, $start = 1)
  84.    ;If UBound($1) <> UBound($2) Return False
  85.    For $i = $start To UBound($1)
  86.       If $1[$i] <> $2[$i] Then Return False
  87.    Next
  88.    Return True
  89. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement