Kovacic Posted December 11, 2015 Share Posted December 11, 2015 Good morning.. I wrote a function but I am not sure if it is correct because my brain is fried.. I am using GDIPlus images as buttons [https://www.autoitscript.com/forum/topic/179132-gdiplus-png-manipulation-not-sure-how-to], hence they have no control ID, and cant be used as buttons any other way that I have found. Because of this, I am trying to make this function return true if the mouse is clicked within a box of coordinates. If someone could, take a look and see if my math is correct here: #cs Usage:_IsInsideOf Use MouseGetPos() to get the mouse click with AutoItSetOption("MouseCoordMode", 0) $coord_x, X location of mouse click $Coord_y, Y location of the mouse click $Loc_X, Left portion of box to check $Loc_y, Top portion of box to check $Siz_x, Height of box $Siz_y Width of box #ce Func _IsInsideOf($coord_x,$Coord_y,$Loc_X,$Loc_y,$Siz_x,$Siz_y) if $coord_x > $Loc_X AND $coord_x < $Loc_X + $Siz_x AND $coord_y > $Loc_y AND $coord_y < $Loc_y + $Siz_y then return true else return false endif endfunc Please take a look and let me know if this looks correct, or you know a simpler way. Thanks in advance!! C0d3 is P0etry( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
ahmet Posted December 11, 2015 Share Posted December 11, 2015 (edited) I think it is good. Here is code to test withGlobal $aPoints[10][2]=[[10,10], [10,45], [300, 23], [112,112], [345,87], [100,234], [22,54], [70,70], [33,33], [220,200]] Global $aRectangle1[4]=[0,0,300,300], $aRectangle2[4]=[220, 113, 370,320] ;x, y, width, height For $i=0 To 9 $bTest1=_IsInsideOf($aPoints[$i][0], $aPoints[$i][1], $aRectangle1[0], $aRectangle1[1], $aRectangle1[2], $aRectangle1[3]) ConsoleWrite("Is (" & $aPoints[$i][0] & ", " & $aPoints[$i][1] & ") in Rect1:" & $bTest1 & @CRLF) $bTest2=_IsInsideOf($aPoints[$i][0], $aPoints[$i][1], $aRectangle2[0], $aRectangle2[1], $aRectangle2[2], $aRectangle2[3]) ConsoleWrite("Is (" & $aPoints[$i][0] & ", " & $aPoints[$i][1] & " in Rect1:" & $bTest2 & @CRLF) NextThere is also a function _WinAPI_PtInRectEx() Edited December 11, 2015 by ahmet Mentioned _WinAPI_PtInRectEx() Link to comment Share on other sites More sharing options...
Malkey Posted December 11, 2015 Share Posted December 11, 2015 TryOpt("MouseCoordMode", 2);1=absolute, 0=relative, 2=clientAn example can be found here. Link to comment Share on other sites More sharing options...
aa2zz6 Posted December 11, 2015 Share Posted December 11, 2015 Is the application in which you are using stationary - always in the same spot? 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