Jump to content

Assistance with PixelSearch and such


Recommended Posts

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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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