Jump to content
Sign in to follow this  
Bigchasedog3

PixelSearch problem

Recommended Posts

Bigchasedog3

ok im working on a little project of mine, and it includes pixelsearch on the screen, however using the @error feature it seems ot be missing the second elseif, meaning its not setting $count to equal 1.

HotKeySet($ExitKey, '_Exit')
$count = 0
$var = 0
While 1
If ($var == 0) Then
  send("{End}")
  sleep(1000)
  MouseClick($ClickMouse, 931, 165, 1, 10)
  sleep(1000)
  send("{UP down}")
  sleep(1500)
  send("{UP up}")
  sleep(1000)
  $var = 1
  sleep(1000)
ElseIf ($var == 1) Then
  $SearchResult = PixelSearch( 735, 442, 745, 630, 0xa9b1b9,10)
  if not @error Then
   Mouseclick($ClickMouse, $SearchResult[0], $SearchResult[1], 1, 10)
   sleep(30000)
   $var = 2
  Elseif @error Then
   sleep(1000)
   $count = 1
  EndIf
Elseif ($var = 1 and $count = 1) Then
  Mouseclick($ClickMouse, 689, 369, 1, 10)
  sleep(1000)
  $count = 0
ElseIf ($var = 2) Then
  PixelSearch( 1034, 636, 1034, 636, 0x0c191f, 5)
  if not @error Then
   $var = 1
  ElseIf (@error = 1) Then
   $var = 3
  EndIf
Elseif ($var = 3) Then
  MouseMove( 944, 417, 10)
  sleep(500)
  Send("{F1}")
  sleep(1000)
  $var = 0
EndIf
WEnd
Func _Exit()
Exit
EndFunc
Edited by Bigchasedog3

Share this post


Link to post
Share on other sites
sliwek

if u have if "1" elseif "2" elseif "2" and "3" ... then will use only one good option so if u have "2" and "3" then it use only first elseif.

try this way:

ElseIf ($var == 1) Then  
  $SearchResult = PixelSearch( 735, 442, 745, 630, 0xa9b1b9,10)  
  if not @error Then  
   Mouseclick($ClickMouse, $SearchResult[0], $SearchResult[1], 1, 10)  
   sleep(30000)  
   $var = 2  
  Elseif @error Then  
   sleep(1000)  
   $count = 1  
  EndIf
If ($var = 1 and $count = 1) Then
   Mouseclick($ClickMouse, 689, 369, 1, 10) 
   sleep(1000)  
   $count = 0
EndIf
ElseIf ($var = 2) Then

or

ElseIf ($var = 1 and $count = 1) Then
   Mouseclick($ClickMouse, 689, 369, 1, 10) 
   sleep(1000)  
   $count = 0
ElseIf ($var == 1) Then  
  $SearchResult = PixelSearch( 735, 442, 745, 630, 0xa9b1b9,10)  
  if not @error Then  
   Mouseclick($ClickMouse, $SearchResult[0], $SearchResult[1], 1, 10)  
   sleep(30000)  
   $var = 2  
  Elseif @error Then  
   sleep(1000)  
   $count = 1  
  EndIf
ElseIf ($var = 2) Then
Edited by sliwek

Share this post


Link to post
Share on other sites
Bigchasedog3

The first one worked, thanks. I knew it was missing the second elseif, but im kinda new to autoit so i wasn't sure of the syntax i should use for it, thanks again.

Share this post


Link to post
Share on other sites
sliwek

if u dont need $count u can do easier way (will do the same):

ElseIf ($var == 1) Then  
  $SearchResult = PixelSearch( 735, 442, 745, 630, 0xa9b1b9,10)  
  if not @error Then  
   Mouseclick($ClickMouse, $SearchResult[0], $SearchResult[1], 1, 10)  
   sleep(30000)  
   $var = 2  
  Elseif @error Then 
   Mouseclick($ClickMouse, 689, 369, 1, 10)  
   sleep(1000)
  EndIf
ElseIf ($var = 2) Then

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  

×