Jump to content

Pixelsearch Multiple colors.


Adergon
 Share

Recommended Posts

HEY ALL!

I tried to make pixelsearch code that chooses a diffrent color if the 1st one isn't found. And the question is if someone can tell me if this code is correct or not? i just mixed something up!;D

$Variable = PixelSearch(505, 215, 539, 262, 0x866C4B)
If IsArray($Variable) = True Then
  MouseClick("Left", $Variable [0], $Variable [1], 1)
  Else
    $Variable = PixelSearch(505, 215, 539, 262, 0x987A55)
  If IsArray($Variable) = True Then
  MouseClick("Left", $Variable [0], $Variable [1], 1)
  Else
    $Variable = PixelSearch(505, 215, 539, 262, 0x7F6647)
  If IsArray($Variable) = True Then
  MouseClick("Left", $Variable [0], $Variable [1], 1)
       EndIf
    EndIf
EndIf

If a proffesional says this is incorrect, then please help me out to improve it!

Link to comment
Share on other sites

Does it not work?

Im not sure actually, becuase i dont know if its finding the first color or the second. :) dunno if you understand.

EDIT: I'm pretty sure all those three pixelcolors are almost exactly the same.

Edited by Adergon
Link to comment
Share on other sites

use ConsoleWrite("found the first color" & @CRLF & @CRLF) in the if statement to report back which color was found. This function only works when running from scite editor. If you don't like scite, use an error file to output.

fileopen() filewrite() will help with that.

Link to comment
Share on other sites

use ConsoleWrite("found the first color" & @CRLF & @CRLF) in the if statement to report back which color was found. This function only works when running from scite editor. If you don't like scite, use an error file to output.

fileopen() filewrite() will help with that.

Hmm, the 2nd option sounds best to me, since i've never used scite. Can you please make an example? :)

Link to comment
Share on other sites

Here is example, click it.

FileWrite

I don't know.. I'm Pretty new to coding this language, so it's pretty hard going from begginner to this type of advanced coding, isn't there another way i could test it or could someone tell me if the code is right? becuase the colors are almost the same and i don't know which one it clicks. But i guess ill just come back here if i suspect it doesn't work. Thanks anyway guys!
Link to comment
Share on other sites

Try this:

$Variable = PixelSearch(505, 215, 539, 262, 0x866C4B)
If IsArray($Variable) = True Then
    MouseClick("Left", $Variable[0], $Variable[1], 1)
    MsgBox(48, "", "First color found!")
Else
    $Variable = PixelSearch(505, 215, 539, 262, 0x987A55)
    If IsArray($Variable) = True Then
        MouseClick("Left", $Variable[0], $Variable[1], 1)
        MsgBox(48, "", "Second color found!")
    Else
        $Variable = PixelSearch(505, 215, 539, 262, 0x7F6647)
        If IsArray($Variable) = True Then
            MouseClick("Left", $Variable[0], $Variable[1], 1)
            MsgBox(48, "", "Third color found!")
        EndIf
    EndIf
EndIf

I took your script and inserted message boxes in the If statements that will pop up and let you know it found a color.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try this:

$Variable = PixelSearch(505, 215, 539, 262, 0x866C4B)
If IsArray($Variable) = True Then
    MouseClick("Left", $Variable[0], $Variable[1], 1)
    MsgBox(48, "", "First color found!")
Else
    $Variable = PixelSearch(505, 215, 539, 262, 0x987A55)
    If IsArray($Variable) = True Then
        MouseClick("Left", $Variable[0], $Variable[1], 1)
        MsgBox(48, "", "Second color found!")
    Else
        $Variable = PixelSearch(505, 215, 539, 262, 0x7F6647)
        If IsArray($Variable) = True Then
            MouseClick("Left", $Variable[0], $Variable[1], 1)
            MsgBox(48, "", "Third color found!")
        EndIf
    EndIf
EndIf

I took your script and inserted message boxes in the If statements that will pop up and let you know it found a color.

OMG! thank you! you're the best!

Link to comment
Share on other sites

$Variable = PixelSearch(505, 215, 539, 262, 0x866C4B)
$file = FileOpen("A.txt",1)
If IsArray($Variable) = True Then
MouseClick("Left", $Variable [0], $Variable [1], 1)
FileWrite($file, "First" & @CRLF)
Else
$Variable = PixelSearch(505, 215, 539, 262, 0x987A55)
If IsArray($Variable) = True Then
  MouseClick("Left", $Variable [0], $Variable [1], 1)
  FileWrite($file, "Second" & @CRLF)
Else
  $Variable = PixelSearch(505, 215, 539, 262, 0x7F6647)
  If IsArray($Variable) = True Then
   MouseClick("Left", $Variable [0], $Variable [1], 1)
   FileWrite($file, "Third" & @CRLF)
  Else
   FileWrite($file, "Neither" & @CRLF)
  EndIf
EndIf
EndIf

Try it.

Link to comment
Share on other sites

$Variable = PixelSearch(505, 215, 539, 262, 0x866C4B)
$file = FileOpen("A.txt",1)
If IsArray($Variable) = True Then
MouseClick("Left", $Variable [0], $Variable [1], 1)
FileWrite($file, "First" & @CRLF)
Else
$Variable = PixelSearch(505, 215, 539, 262, 0x987A55)
If IsArray($Variable) = True Then
  MouseClick("Left", $Variable [0], $Variable [1], 1)
  FileWrite($file, "Second" & @CRLF)
Else
  $Variable = PixelSearch(505, 215, 539, 262, 0x7F6647)
  If IsArray($Variable) = True Then
   MouseClick("Left", $Variable [0], $Variable [1], 1)
   FileWrite($file, "Third" & @CRLF)
  Else
   FileWrite($file, "Neither" & @CRLF)
  EndIf
EndIf
EndIf

Try it.

I'm gonna try both :) people at this forum is really helpful! thanks.
Link to comment
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
 Share

  • Recently Browsing   0 members

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