Sign in to follow this  
Followers 0
moth

Help with pixel search

2 posts in this topic

Dim $ClickMouse, $MousePrimary, $MouseSecondary, $ExitKey
Dim $Color, $Left, $Top, $Right, $Bottom, $SearchResult, $CheckSwap
Dim $Bufftimer
$ExitKey = "{ESC}"
$Color = 0x70635B
$Left = 1
$Top = 1
$Right = 1024
$Bottom = 800
$ClickMouse = $MousePrimary
$Bufftimer = 50
$CordX1 = 520
$CordY1 = 416
$CordX2 = 612
$CordY2 = 439
$Bufftimer = 0
HotKeySet("{F12}", '_Exit')

While 1
 
 
   $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color)
   If Not @error Then
   MouseClick($ClickMouse, $SearchResult[0], $SearchResult[1], 2, 5)
  MouseClick("right", $SearchResult[0], $SearchResult[1], 2, 1)
  
  If $Bufftimer = 100 Then
  Sleep(15000)
  Send("{F9}")
  Send("{F9}")
  Send("{F9}")
  Send("{F9}")
  Sleep(3000)
  Send("{F6}")
  Send("{F6}")
  Send("{F6}")
  Send("{F6}")
  Sleep(3000)
  Send("{F7}")
  Send("{F7}")
  Send("{F7}")
  Send("{F7}")
  Sleep(3000)
  Send("{F8}")
  Send("{F8}")
  Send("{F8}")
  Send("{F8}")
  Sleep(3000)
  Send("{F5}")
  Send("{F5}")
  Send("{F5}")
  Send("{F5}")
  Sleep(3000)
  Send("{SPACE}") 
  Send("{SPACE}")
  Send("{SPACE}")
  Send("{SPACE}")
  Send("{SPACE}")
  Sleep(2000)
  MouseClick("left",$CordX1,$CordY1,1,2)
  Sleep(2000)
  MouseClick("left",$CordX2,$CordY2,1,2)
  Sleep(1000)
  $Bufftimer = 0
EndIf

  Send ("{F4}{f2}")
  sleep(8000)
  Send('{Right down}')
  Sleep(300)
  Send('{Right up}')
  sleep(800)
  $Bufftimer = $Bufftimer  + 1
  EndIf
 

   
WEnd
Func _Exit()
Exit
EndFunc

Hey guys, i would need some guidelines on how to make this code even better, i know now that it searches pixels from 1,1 to 1024,800. But what id like it to do now is to first search, the inner square, if pixel is not found, make it go to the middle square, and if nothing there either make it go check outer square. Now i know the basics and that i can use if else etc, but i dont know how i can confirm that it has found a color. So any help with this is fine :D

Picture:

Posted Image

Thanks you in advance, moth

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If True Then


  $SearchResult = PixelSearch(260, 250, 760, 600, $Color, 1)      ; Search inner area for color
  If Not @error Then             ; if not error continue
  MouseClick($ClickMouse, $SearchResult[0], $SearchResult[1], 2, 5) ;CLICK
  MouseClick("right", $SearchResult[0], $SearchResult[1], 2, 1)     ;CLICK
  


  Else               ; if color is not found in in small rectangle go here
  $SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color, 1)  ; Search the whole area     
  If Not @error Then               ; if not error continue  
  MouseClick($ClickMouse, $SearchResult[0], $SearchResult[1], 2, 5)     ;CLICK
  MouseClick("right", $SearchResult[0], $SearchResult[1], 2, 1)     ;CLICK

EndIf                ;Break out of sub-ifloop
EndIf                  ; break out of if loop

Alright this is what i got, its working well atm, can somone please just look through it and tell me if there are any obvious bugs or stuffs :D Thanks

Also, is there any way to be able to put in 2 colors in the $Color variable Like, if either one of these colors are found, click them?

Edited by moth

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0