Teddilord Posted June 16, 2009 Share Posted June 16, 2009 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 Link to comment Share on other sites More sharing options...
oMBRa Posted June 16, 2009 Share Posted June 16, 2009 I suggest you to try this UDF: Find BMP in another BMP Link to comment Share on other sites More sharing options...
herewasplato Posted June 16, 2009 Share Posted June 16, 2009 (edited) 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=19722Pay 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 June 16, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Teddilord Posted June 16, 2009 Author Share Posted June 16, 2009 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. Link to comment Share on other sites More sharing options...
junkew Posted June 16, 2009 Share Posted June 16, 2009 (edited) 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+bmpTrue;16;1558;1004;16;16;-1;-1 car.bmp in SCREEN ** matchtype 1 time elapsed: 1793.08468602133 millisecondssave the 16*16 car as car.bmpMake sure that what you are looking for is visible on the screenGlobal Const $Bitmap12Filename = @TempDir & "\car.bmp"findTester("SCREEN",$Bitmap12Filename,$c24RGBFullMatch) ;Find the carcar.bmp Edited June 16, 2009 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now