Jump to content
Sign in to follow this  
Teddilord

Assistance with PixelSearch and such

Recommended Posts

Teddilord

Hi, I'm trying toautomate some work using an inhouse application that uses very few standard window controls. Thus I need to identify a window that is expected to pop up by finding an icon (15x15 px) of a bright green truck. This however fails, and I have torn my hair over this for hours, and nothing I can think of works.

The problem (i suspect) lies in the PixelSearch inside the FindTheGreenTruck function. The function always returns false even when I know the truck is visible. I have measured the color of the truck with the window finder, and it is 0x00FF00. I have posted the code I think is relevant, I can however post more if required (however the whole code is some 230 lines with comments in a scandinavian language).

I would appreciate any help I can get! (I attatched the green truck to the post, if it helps...)

CODE

;Much more code above

sleep(2000)

ConnectOneEcu($EcuType)

sleep(2000)

NavigateMenus("Module", 1, false, 1)

;New window pops up

Sleep(2000)

$GTpos=FindTheGreenTruck()

if not $GTpos==False then

MouseClick("", $GTpos[0]+18, $GTpos[1]+18, 2, 0)

Else

MsgBox(0, "Error", "Could not find green truck")

EndIf

Func FindTheGreenTruck ()

$retval=PixelSearch(2, 130, 760, 560, 0x00FF00, 64)

if @error Then

return False

Else

Return $retval

EndIf

EndFunc

;Much more code below

post-50778-1245145231_thumb.jpg

Share this post


Link to post
Share on other sites
oMBRa

I suggest you to try this UDF: Find BMP in another BMP

Share this post


Link to post
Share on other sites
herewasplato

Welcome to the forum.

I would use PixelCheckSum for this just in case there is another spot that has the same green color.

Some night when you cannot sleep - read thru the script and comments in this post:

http://www.autoitscript.com/forum/index.php?showtopic=19722

Pay attention to:

AutoItSetOption("PixelCoordMode", 0)

AutoItSetOption("MouseCoordMode", 0)

If you do decide to use that tool (it does not do into your script) you can change the output to use it with PixelCheckSum.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Teddilord

Thank you for your help, I will check out those options. However, it turns out the functionality I was having trouble with was not in the specification anyways. However, the feature might still be handy to have.

Share this post


Link to post
Share on other sites
junkew

On my not so fast machine it takes 1-2 seconds to find the car with http://www.autoitscript.com/forum/index.ph...amp;hl=find+bmp

True;16;1558;1004;16;16;-1;-1 car.bmp in SCREEN ** matchtype 1 time elapsed: 1793.08468602133 milliseconds

save the 16*16 car as car.bmp

Make sure that what you are looking for is visible on the screen

Global Const $Bitmap12Filename = @TempDir & "\car.bmp"

findTester("SCREEN",$Bitmap12Filename,$c24RGBFullMatch) ;Find the car

car.bmp

Edited by junkew

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.