Sign in to follow this  
Followers 0
Guest KidIcarus

PixelSearch Broken?

16 posts in this topic

I am using AutoItX v3.1.1 with Visual Basic .NET. The PixelSearch function doesn't seem to be working for me. The string it returns is always empty not matter what variables I pass in. There is also no error when I check the error flag. Anyone able to get PixelSearch to wotk in AutoItX?

Share this post


Link to post
Share on other sites



Did you ever get a response to this? I just ran into the same problem when looking for a Red read flag in an old legacy application.

I am using AutoItX v3.1.1 with Visual Basic .NET. The PixelSearch function doesn't seem to be working for me. The string it returns is always empty not matter what variables I pass in. There is also no error when I check the error flag. Anyone able to get PixelSearch to wotk in AutoItX?

Share this post


Link to post
Share on other sites

I must be missing something in that thread. Im using AutoItX and have the problem

Example in Python when using the PixelSearch function of The AutoItX.dll

import win32com.client
o = win32com.client.Dispatch( "AutoItX3.Control" )

# ----------- Configure defaults for AutoItX -----------------
o.AutoItSetOption("SendKeyDelay", 5)  #making sure its the default setting of 5
o.AutoItSetOption("ColorMode", 0)    #make sure we are RGB mode
o.AutoItSetOption("PixelCoordMode",1) #make sure we are in absolute screen Coord mode

 Get color at x,y
# -----------------------------------------------------------------------------
def GetColor(x,y):
    rcolor = o.PixelGetColor(x,y)
    return rcolor

p = GetColor(20,20)

z = o.PixelSearch(1,1,50,50, p)

print z

When ran, you get the following

>>> z
u'1'

Is that a string with the Coords? what format do I use to read it?

Share this post


Link to post
Share on other sites

Very Sorry... this is not for autoitX

8(


NEWHeader1.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Me too...

I am using AutoItX v3.1.1 with Visual Basic .NET. The PixelSearch function doesn't seem to be working for me. The string it returns is always empty not matter what variables I pass in. There is also no error when I check the error flag. Anyone able to get PixelSearch to wotk in AutoItX?

Im seeing the same thing when using AutoIt3x from python. The string I get back is either empty

or "1", but never anything else. It's also odd that when doing a big search (1,1,1000,1000) for

for 0x000000, it returns instantly, but when searching for 0x000001 it takes some time.

Anyone else?

Edited by dBeau

Share this post


Link to post
Share on other sites

And I thought I was going crazy with this. I rewrote most of my python code in perl today and still am seeing the same problem. Also the time issue is true too.

- RR

Me too...

Im seeing the same thing when using AutoIt3x from python. The string I get back is either empty

or "1", but never anything else. It's also odd that when doing a big search (1,1,1000,1000) for

for 0x000000, it returns instantly, but when searching for 0x000001 it takes some time.

Anyone else?

Share this post


Link to post
Share on other sites

I'd have to guess that at least part of the problem that the length of the return string

is not getting set properly. I'd love to see the sources to confirm. I cant even imagine

what would cause the time issue.

And I thought I was going crazy with this. I rewrote most of my python code in perl today and still am seeing the same problem. Also the time issue is true too.

- RR

Share this post


Link to post
Share on other sites

Pixel search is very slow. What are you using it for?

Share this post


Link to post
Share on other sites

Currently, I am using it for hunting down red flags within a window. The email application is graphical simulation of a Palm PDA.

Pixel search is very slow. What are you using it for?

Share this post


Link to post
Share on other sites

I noticed the same thing, so I made my own function, it works 100%

private int[] PixelSearch(int startX,int startY,int rangeX,int rangeY, int step,int color)
        {
            for(int x=startX;x<startX+rangeX;x+=step)
            {
                for(int y=startY;y<startY+rangeY;y+=step)
                {
                    if(autoit.PixelGetColor(x,y)==color)
                        return new int[]{x,y};
                }
            }
            throw new ApplicationException("PixelSearch: Failed to find the color ("+color.ToString()+")");
        }

Share this post


Link to post
Share on other sites

Why would you throw an exception? Why not just return null?

Share this post


Link to post
Share on other sites

Have you seen an problems with a hit on speed? I started to do this a month ago, but was worried it might be slow not being native CPU code.

I might be missing this in your included code, but did you manage copy PixelSearch's shade-variation option ? The PDA code I need to test often shifts the colors depending on what else might be running.

I noticed the same thing, so I made my own function, it works 100%

private int[] PixelSearch(int startX,int startY,int rangeX,int rangeY, int step,int color)
        {
            for(int x=startX;x<startX+rangeX;x+=step)
            {
                for(int y=startY;y<startY+rangeY;y+=step)
                {
                    if(autoit.PixelGetColor(x,y)==color)
                        return new int[]{x,y};
                }
            }
            throw new ApplicationException("PixelSearch: Failed to find the color ("+color.ToString()+")");
        }

Share this post


Link to post
Share on other sites

I throw an exception because... I have no clue actually lol, im not a programmer just doing this for fun and I was playing with exception handling when I made this code.

and also I didn't put shade variation, this was needed for pixel searchs with predefined colors with 0-shade, but it would be a nice idea actually yes.

and speed looks the same, havent saw any difference from default autoit pixelsearch function.

Share this post


Link to post
Share on other sites

It is quite frustrating to get it to work in .NET, but with a little time it is simple.

CODE
dim x as integer

dim y as integer

dim search as object

search = (your autoitx control variable).PixelSearch(left,top,right,bottom,color,Nvar?,step)

x = search(0)

y = search(1)

:)

Share this post


Link to post
Share on other sites

It is quite frustrating to get it to work in .NET, but with a little time it is simple.

CODE
dim x as integer

dim y as integer

dim search as object

search = (your autoitx control variable).PixelSearch(left,top,right,bottom,color,Nvar?,step)

x = search(0)

y = search(1)

:)

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