Advertisement
twiz

SearchClick

Dec 8th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SearchClick(Image, Button="Left", ClickCount="1", ByRef XPos="", ByRef YPos="", StartX="0", StartY="0", EndX="0", EndY="0", Options="", OffsetX="0", OffsetY="0") {
  2.     WinGetPos,,, WinW, WinH, A
  3.     ;       ( IF      ? Then : Else)
  4.     EndX := (EndX = 0 ? WinW : EndX)
  5.     EndY := (EndY = 0 ? WinH : EndY)
  6.     ImageOptions := (Options = "" ? Image : Options " " Image)
  7.  
  8.     Found := 0
  9.     While !(Found OR A_Index>5) {
  10.         ImageSearch, XPos, YPos, (StartX), (StartY), (EndX), (EndY), %ImageOptions%
  11.         If (ErrorLevel = 0) {
  12.             MouseClick, %Button%, (XPos + OffsetX), (YPos + OffsetX)
  13.             Found := 1
  14.         }
  15.         Else IF (ErrorLevel = 2) {
  16.             MsgBox % "Problem opening image!`n" Image
  17.             Break
  18.         }
  19.         Else {
  20.             Sleep 200
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement