Jump to content
Sign in to follow this  
mastermc

Pixel Search help

Recommended Posts

mastermc

OK i am trying to make this bot to auto farm for me. but the problem is i want to be able to change the color it looks for without having to go into the code and make it another exe. So i thought i would use a input box and have it search for what ever color i put in there. Need less to say it didn't work. I doesn't click the color, it just goes of randomly clicking :D things.

#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#Include <WindowsConstants.au3>
#include <Editconstants.au3>

Global $Form1 = GUICreate("Auto Famer", 256, 188, 491, 312)
Global $label1=GuiCtrlCreatelabel("Color One:",5, 24)
Global $Input1 = GUICtrlCreateInput("", 120, 16, 105, 21)
Global $Start = GUICtrlCreateButton("Start", 8, 136, 105, 25, 0)
Global $Stop = GUICtrlCreateButton("Stop", 136, 136, 113, 25, 0)

While
      $pos = PixelSearch(0, 0, @DeskTopWidth, @DeskTopHeight, $Input1, 1, 1)
         If @error Then
            MouseClickDrag("right",400,500,500,500,0)

         Else
                    MouseMove($pos[0], $pos[1], 1)
                        Sleep (1000)
                        MouseClick("left", $pos[0], $pos[1], 1)
                        Sleep (500)
         EndIf
         Sleep(10)
WEnd

Can anyone help tell me what is wrong with it. I also tried doing it ini files style but that end up with the same results.

:o

Share this post


Link to post
Share on other sites
TerarinK

As Authenticity said but I would like to say your processing in a game and instancely doing stuff then waiting a minute will get you banned.

#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Global $hForm = GUICreate("Auto Famer", 256, 188, 491, 312)
Global $vLabel = GUICtrlCreateLabel("Color One:", 5, 24)
Global $vInput = GUICtrlCreateInput("", 120, 16, 105, 21)
Global $vStart = GUICtrlCreateButton("Start", 8, 136, 105, 25, 0)
Global $vStop = GUICtrlCreateButton("Stop", 136, 136, 113, 25, 0)

While 1
    $iPos = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, GUICtrlRead($vInput), 1, 1)
    If @error Then
        MouseClickDrag("right", 400, 500, 500, 500)
    Else
;       MouseMove($pos[0], $pos[1], 50)
        MouseClick("left", $iPos[0], $iPos[1], 50)
    EndIf
    Sleep(100)
WEnd

Also do note the MouseMove as you don't need it as MouseClick will move your mouse for you and proceed to click. Also you have no start or stop method implemented, so those are blank


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites
mastermc

ok i did what you recommended but now i have a new problem

Global $Form1 = GUICreate("Auto Famer", 256, 188, 491, 312)
Global $label1=GuiCtrlCreatelabel("Color One:",5, 24)
Global $Input1 = GUICtrlCreateInput("", 120, 16, 105, 21)
Global $Start = GUICtrlCreateButton("Start", 8, 136, 105, 25, 0)
Global $Stop = GUICtrlCreateButton("Stop", 136, 136, 113, 25, 0)
$msg=0 

While 1
            Select 
        Case $Msg = $Start
            Do
        $pos = PixelSearch(0, 0, @DeskTopWidth, @DeskTopHeight, GUICtrlRead $Input1, 1, 1)
            If @error Then
                MouseClickDrag("right",400,500,500,500,0)

            Else
                 MouseClick("left", $pos[0], $pos[1], 50)
            EndIf
            Sleep(10)
        Until $Msg = $Stop
            EndSelect
WEnd

I have this but now the window where i enter the color wont appear just the icon in my icon tray. how do i fix that part?

Share this post


Link to post
Share on other sites
TerarinK

You are missing the declaring of the GUI. You always need a GUISetState() right after you declare everything or even before if you want it to be special, long decussion on that topic


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.