Jump to content

Recommended Posts

Posted

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)

Posted

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
Posted

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)
Posted

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.

Posted

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.

Posted

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
Posted

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

Posted

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
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
  • Moderators
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

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.

  • Moderators
Posted

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

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...