Sign in to follow this  
Followers 0
Skuller74

Find Color -> Do this

17 posts in this topic

Is there a way i could do something like this?

I want to make a script for fishing in WoW

for $x = 1 to 9000

MouseClick("Left", "1000", "690", "1")

$Variable = Find color 0x000000 (or any other color, where variable will store the coordinates)

MouseClick("Right", "X", "Y", "1") - (X and Y from Variable somehow)

Sleep(2000)

MouseClick("Left", "35, "200", "1")

Sleep(1000)

so is this possible? B)

Share this post


Link to post
Share on other sites



? you want to do that 9000 times why not just do a loop? and someone else can edit your script

Share this post


Link to post
Share on other sites

I dont know how to do an infinite loop B)

and what do you mean, someone else can edit my script?

Share this post


Link to post
Share on other sites

To find a colour you use the PixelSearch() function. An infinite loop is shown in the example below, which assumes that you want to search the entire screen for that pixel.

Local $Coords

While 1
    MouseClick('', 1000, 690, 1, 0)
    $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0x000000)
    If @Error Then
       ; The colour was not found
    Else
       ; The colour was found
        MouseClick('Right', $Coords[0], $Coords[1], 1, 0)
        Sleep(2000)
        MouseClick('', 35, 200, 1, 0)
    EndIf
    Sleep(1000)
WEnd

Share this post


Link to post
Share on other sites

of wow thanks :o

oh, and one more thing, since you just said....

which assumes that you want to search the entire screen for that pixel.

how would you search a limited area? B)

Share this post


Link to post
Share on other sites

To search a limited area you would adjust the first four inputs to PixelSearch() as necessary. AutoIt Window Info gives you the screen coordinates of the mouse which may help you choose the right values.

Share this post


Link to post
Share on other sites

oh okay, thanks :graduated:... and ONE more thing B)

How could I make it search for multiple colors and if it finds ONE of them, go to else. An or statement.

I tried this script today and it worked... once :o because it randomly places the bobber for fishing on the screen so the pixel colors change as it gets closer or farther away. So I want to get many pixels from up close and from farther away.

Share this post


Link to post
Share on other sites

try using this code-

(edited from above)

Local $Coords

While 1
    MouseClick('', 1000, 690, 1, 0)
    $Coord1 = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0xCOLOR)
    $Coord2 = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0xCOLOR)
   ;and so on..
    If @Error Then
      ; The colour was not found
    Else
      ; The colour was found
        MouseClick('Right', $Coord1[0], $Coord1[1], 1, 0)
        MouseClick('Right', $Coord2[0], $Coord2[1], 1, 0)
        Sleep(2000)
        MouseClick('', 35, 200, 1, 0)
    EndIf
    Sleep(1000)
WEnd

Share this post


Link to post
Share on other sites

never mind, that doesn't work...

Share this post


Link to post
Share on other sites

this might help you find the color and code

and the mouse position

;*********** Use **************
; Press Esc to terminate script
; Press F8 to open a color dialog box and choose a color
; Or
; Press F9 to get the color under the mouse pointer
; by Valuater...... Enjoy!!!  
;******************************
#include <GuiConstants.au3>
#include <Misc.au3>
Global $var, $Color_win, $pos
HotKeySet("{F8}", "Color_Box")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "Get_Color") 

ToolTip('Get Color - is Running',0,0)
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func Color_Box()
    $var = _ChooseColor (2)
    Show_Color()
EndFunc
Func Terminate()
    Exit 0
EndFunc
Func Get_Color()
    $pos = MouseGetPos()
    $Svar = PixelGetColor(  $pos[0] , $pos[1])
    $var = "0x" & Hex($Svar,6)
    Show_Color()
EndFunc
Func Show_Color()
    GUIDelete($Color_win)
    ClipPut($var)
    $Color_win = GUICreate("RGB Color = " & $var, 290, 150, -1, -1)
    GUISetBkColor($var)
    GUISetFont(9, 400, -1, "MS Sans Serif")
    GUICtrlCreateLabel(" This Color has been Copied to the ClipBoard  " & @CRLF & @CRLF & "  Just Paste it wherever you would like"& @CRLF & @CRLF & @CRLF & " Mouse position X=" & $pos[0] & "  Y=" & $pos[1]   , 10, 10, 270, 100)
    GUICtrlSetFont(-1, 9, 650)
    If $var = 0x000000 Then GUICtrlSetColor( -1, 0xFFFFFF) 
    $OK_Btn = GUICtrlCreateButton("&OK", 100, 110, 80, 30)
    GUISetState()
    While 2
        $msg1 = GUIGetMsg()
        If $msg1 = $OK_Btn Or $msg1 = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete($Color_win)   
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

yeah, but how do we search for multiple colors so if either color shows up on the screen, it clicks it.

Share this post


Link to post
Share on other sites

I tried this script today and it worked... once B) because it randomly places the bobber for fishing on the screen so the pixel colors change as it gets closer or farther away. So I want to get many pixels from up close and from farther away.

PixelSearch() has a shade variation setting. It can detect pixels within a specified range of the given colour. Refer to the help file for more details on that.

How could I make it search for multiple colors and if it finds ONE of them, go to else. An or statement.

This will do it but it will be twice as slow since it must scan the entire screen twice:

Local $CoordsA, $CoordsB

While 1
    MouseClick('', 1000, 690, 1, 0)
    $CoordsA = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0x000000)
    $CoordsB = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0xFFFFFF)
    If IsArray($CoordsA) Then
      ; The colour A was found
        MouseClick('Right', $CoordsA[0], $CoordsA[1], 1, 0)
        Sleep(2000)
        MouseClick('', 35, 200, 1, 0)
    Else
      ; The colour A was not found
    EndIf
    If IsArray($CoordsB) Then
      ; The colour B was found
        MouseClick('Right', $CoordsB[0], $CoordsB[1], 1, 0)
        Sleep(2000)
        MouseClick('', 35, 200, 1, 0)
    Else
      ; The colour B was not found
    EndIf
    Sleep(1000)
WEnd

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

oh alright, that makes sense... thanks man B)

edit:

I checked the help file, that shade variation will really help in finding the bobber, thanks

Edited by Skuller74

Share this post


Link to post
Share on other sites

is there a way to make it scan faster?

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

If you're doing a search, I believe Larry posted a PixelSearch that is a bit faster in the Sripts and Scraps part of the forum... :P Maybe it was in the Idea Lab?

Edit

Actually, it was the Developers forum: PixelSearch()

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

thats too confusing.... it's all about dll stuff...

Share this post


Link to post
Share on other sites

Well you asked if there was anything faster... you didn't ask if it was simple :P, but it looks pretty straight up.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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