Jump to content
Sign in to follow this  
alt201

Why is this code being called in this conditional?

Recommended Posts

Hi, I'm making a bot where it does a pixel scan of a small area to identify colors and let me know what zone I am in, but for some reason this conditional keeps getting called. The conditional "ElseIF" keeps getting called in the code below even though it should be false because the pixelscan is searching for and finding the color I specified. Here is the code

HotKeySet("{end}", "MyExit")
AutoItSetoption("MouseCoordMode", 0)

WinActivate("World of Warcraft")
  WinWaitActive("World of Warcraft")

$av = 0
$test = 0

Sleep(1500)
Send("{space}")
sleep(3000)

While 1
    Sleep(200)
$coord = PixelSearch( 886, 7, 959, 19, 0x207618, 20, 1 )
    
If @error <> 1 Then;If it finds the color then click to queue once, else it goes to AV function
    
    If $test = 0 Then;Not queued
        Sleep(2000)
          MouseClick("right", 295, 326, 1)
        Sleep(2000)
        $test = 1
        $av = 0
    EndIf
    
Elseif @error == 1 then;IN AV                ;<------ THIS LINE IS GETTING CALLED WHEN IT SHOULD BE FALSE 
                                                                       ;           BECAUSE PIXELSCAN IS FINDING THE PIXEL IT NEEDS
    
    If $av = 0 Then                
        Sleep(Random(2000,4000,1))
        send("{space}")
        Sleep(10000)
        Send("{w down}") 
        sleep(1900)
        Send("{d down}")
        sleep(295)
        Send("{d up}")
        sleep(22000)
        Send("{a down}")
        sleep(200)
        Send("{a up}")
        sleep(5000)
        send("{w up}")
        
        $av = 1
    Else    
      Sleep(Random(120000,240000,1));Randomly jump between 2 to 4 minutes
      ControlSend("World of Warcraft", "", "", "{space}")
      $test = 0
      
    EndIf
Endif

WEnd

Func MyExit()
  Exit
EndFunc

Any help with the syntax or logic would be greatly appreciated. I know that the pixelscan is successful because it executes the code beneath it, it just seems that my else statement isn't working

Edited by alt201

Share this post


Link to post
Share on other sites

Failure Sets @error to 1 if color is not found.

Elseif @error == 1 then;IN AV

Another self explainitory

Not catching what you mean, it seems like you just repeated my code

btw this is a new acc (because I can't remember my old info) but I've been here for a solid 3 years, I used to come to this site a long time ago years ago, it's been like 3 years since I've even touched anything to do with programming so I'm very rusty.

Anyways if you could elaborate and help me out, thank you for your time.

Share this post


Link to post
Share on other sites

To clarify the elseif statement is being called when @error is not 1 it should only be called when it's unsuccessful for my code to work

Share this post


Link to post
Share on other sites

try this to get more information

; make sure you are getting the info you want
#include <AutoitInfo.au3>

; to see where the pressed line is - place the mouse over the Tray Icon
Opt("TrayIconDebug", 1)         ;0=no info, 1=debug line info


HotKeySet("{end}", "MyExit")
AutoItSetOption("MouseCoordMode", 0) ; I would think of using this as # 1 instaed of 0 ( not sure of the screen size etc of WoW

; removed for my testing
WinActivate("World of Warcraft")
WinWaitActive("World of Warcraft")

$av = 0
$test = 0

Sleep(1500)
Send("{space}")
Sleep(3000)

While 1
    Sleep(200)
    $coord = PixelSearch(886, 7, 959, 19, 0x207618, 20, 1)

    If @error <> 1 Then;If it finds the color then click to queue once, else it goes to AV function

        _AutoitInfoDisplay ($coord, "PixelSearch", 2) ; will display coordinates if no error
        
        If $test = 0 Then;Not queued
            Sleep(2000)
            MouseClick("right", 295, 326, 1)
            Sleep(2000)
            $test = 1
            $av = 0
        EndIf

    ElseIf @error == 1 Then;IN AV                 ;<------ THIS LINE IS GETTING CALLED WHEN IT SHOULD BE FALSE
        ;           BECAUSE PIXELSCAN IS FINDING THE PIXEL IT NEEDS

        If $av = 0 Then
            
            _AutoitInfoDisplay ("#1 error = " & @error & "  AV = " & $av & "  test = " & $test, "PixelSearch", 2)
            
            Sleep(Random(2000, 4000, 1))
            Send("{space}")
            Sleep(10000)
            Send("{w down}")
            Sleep(1900)
            Send("{d down}")
            Sleep(295)
            Send("{d up}")
            Sleep(22000)
            Send("{a down}")
            Sleep(200)
            Send("{a up}")
            Sleep(5000)
            Send("{w up}")

            $av = 1
        Else
            _AutoitInfoDisplay ("#2 error = " & @error & "  AV = " & $av & "  test = " & $test, "PixelSearch", 2)
            Sleep(Random(120000, 240000, 1));Randomly jump between 2 to 4 minutes
            ControlSend("World of Warcraft", "", "", "{space}")
            $test = 0

        EndIf
    EndIf

WEnd

Func MyExit()
    Exit
EndFunc   ;==>MyExit

I cant test your code, i dont have WOW

You will need this AutoitInfo.au3 located here....

http://www.autoitscript.com/forum/index.ph...st&p=446841

8)

Edited by Valuater

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  

×
×
  • Create New...