£åߥ®Ñth Posted December 15, 2009 Share Posted December 15, 2009 (edited) Here is the deal. This small script finds the windows calculator process. Then finds the handle of the F-E button on the Scientific Calculator. Then it is supposed to find a "Pink" pixel on the button. It does not find a pixel at all on the button.?. Can anyone explain whats wrong? AutoItSetOption("PixelCoordMode", 2) If ProcessExists("calc.exe") Then MsgBox(0, "process Found", "continue") EndIf $handle = ControlGetHandle("Calculator", "", "[CLASS:Button; INSTANCE:22]") If Not @error Then MsgBox(0, "found", "found button F-E") EndIf $coord = PixelSearch(0, 0, 31, 24, 0xFF6DF4, 0, 0, $handle) If Not @error Then MsgBox(0, "X and Y of Button F-E:", $coord[0] & "," & $coord[1]) EndIf Exit (0) Now if i do it like this it returns a 1 on both message boxes indicating the pixel was found? Other wise "True" WTH? AutoItSetOption("PixelCoordMode", 2) $cal = "Calculator" $button = "[CLASS:Button; INSTANCE:22]" If ProcessExists("calc.exe") Then MsgBox(0, "process Found", "continue") EndIf $handle = ControlGetHandle($cal, "", $button) If Not @error Then MsgBox(0, "found", "found button F-E") EndIf $coord = PixelSearch(0, 0, 31, 24, 0xFF6DF4, 0, 0, $button) MsgBox(0, "Test:", $coord) If Not @error Then MsgBox(0, "Test", $coord) EndIf Exit (0) Edited December 15, 2009 by £åߥ®Ñth Link to comment Share on other sites More sharing options...
GEOSoft Posted December 15, 2009 Share Posted December 15, 2009 (edited) From the Help file under PixelSearch() Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y). $coord = PixelSearch(0, 0, 31, 24, 0xFF6DF4, 0, 0, $button) ;MsgBox(0, "Test:", $coord) ;as soon as you click OK the error level ia reset causing the next line to fail If Not @error Then MsgBox(0, "Test", "X = " & $coord[0] & @CRLF & "Y = " & $coord[1]) EndIf Edited December 15, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Delta Posted December 15, 2009 Share Posted December 15, 2009 Do you just need the position of the F-E Button? If so try ControlGetPos instead of pixel search. $coord = ControlGetPos("Calculator", "", "[CLASS:Button; INSTANCE:22]") If Not @error Then MsgBox(0, "X and Y of Button F-E:", $coord[0] & "," & $coord[1]) EndIf [size="1"]Please stop confusing "how to" with "how do"[/size] Link to comment Share on other sites More sharing options...
£åߥ®Ñth Posted December 16, 2009 Author Share Posted December 16, 2009 No, Trying to detect a pixel on the button. Not trying to target the control to give it a press. Pixelsearch is returning 1 because the pixel is detected. PixelGetColor will return coords of the color on the button. So problem solved. Link to comment Share on other sites More sharing options...
jvanegmond Posted December 16, 2009 Share Posted December 16, 2009 Are you sure PixelSearch accepts an handle to a control instead of a window? github.com/jvanegmond Link to comment Share on other sites More sharing options...
£åߥ®Ñth Posted December 16, 2009 Author Share Posted December 16, 2009 Problem solved already Manador thanks man. 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