Jump to content

PixelSearch Help


 Share

Recommended Posts

Hello, I am attempting to write a script that will search for a pixel on the screen and then once it has found that pixel execute a mouse command, I was running into an error and had a few other questions regarding my script.

The error that I am getting is stating that:

If (x > 0) Then

If (^ ERROR

Error: Error parsing function call.

From what I understand from reading the pixelsearch help at http://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm it should, if it finds the color, store it in an x and y array. Why can't I then call on this array in this form:

Func FindColor()
   $x = 0
   $y = 0
PixelSearch (1037, 584, 1296, 612, 0x27CD3A)
If (x > 0) Then
   MouseUp ("Left")
Else
   EndIf
EndFunc

The other question I have is if this color, 0x27CD3A is in BGR, and pixelsearch reads in RGB, do I just re-order them and it will work, or can I change it to BGR?

Link to comment
Share on other sites

Try this:

Func FindColor()
$RESULT = PixelSearch (1037, 584, 1296, 612, 0x27CD3A)
If NOT @error then
MouseUp ("Left")
Else
EndIf
EndFunc

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Hi, I am no longer getting the error with this so thank you for that!

Do you know if you can change the format from RGB to BGR by rearranging them? If not, is there a way to make it scan in BGR instead of RBG or any other mode for that matter?

Link to comment
Share on other sites

Yup, just change BGR to RGB. For example:

In BGR: 0x0010FF

In RGB: 0xFF1000

I hope all's clear now.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Hey, this is my last post for the day since i have a post limit, can you explain what the $RESULT = does? If I wanted to make it in a loop to continue searching for it until it was found, or all instances were I would use a Do function, but what would the Until be?

Thank you again for your help and quick answers

Link to comment
Share on other sites

They say little knowledge is dangerous thing, but doing things with zero knowledge is bound to cook your brain. So, take your time reading and understanding this book first: AutoIt v3 Quick Guide

See you soon. ;)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Hey, this is my last post for the day since i have a post limit, can you explain what the $RESULT = does? If I wanted to make it in a loop to continue searching for it until it was found, or all instances were I would use a Do function, but what would the Until be?

Thank you again for your help and quick answers

Something like this?

Func FindColor()
Do
If PixelSearch (1037, 584, 1296, 612, 0x27CD3A) Then
MouseUp("Left")
EndIf
Until PixelSearch (1037, 584, 1296, 612, 0x27CD3A) = True
EndFunc

I didn't use the $RESULT but u can use it. It makes it a variable.

Edit: Make it continue searching for it

Func FindColor()
 While 1
  Do
   PixelSearch (1037, 584, 1296, 612, 0x27CD3A)
  Until PixelSearch (1037, 584, 1296, 612, 0x27CD3A) = True
 WEnd
EndFunc
While 1
 FindColor()
WEnd
Edited by ileandros

I feel nothing.It feels great.

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...