Celtic88 Posted July 16, 2013 Share Posted July 16, 2013 (edited) Gets the mouse cursor position relative to CONTROL ? Edited July 16, 2013 by Mrbenkali Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 Hi, Yes you can, think a little. Link to comment Share on other sites More sharing options...
Celtic88 Posted July 16, 2013 Author Share Posted July 16, 2013 you can do it in my example ! Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 you can do it in my example ! Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 (edited) Hints: Ctrl coords, Mouse coords; Difference. Edited July 16, 2013 by FireFox Link to comment Share on other sites More sharing options...
Celtic88 Posted July 16, 2013 Author Share Posted July 16, 2013 How to do in this example #include <GUIConstantsEx.au3> Global $x, $y Example() Func Example() Local $msg HotKeySet("{Esc}", "GetPos") GUICreate("Press Esc to Get Pos", 400, 400) $x = GUICtrlCreateLabel("0", 10, 10, 50) $y = GUICtrlCreateLabel("0", 10, 30, 50) $Pic1 = GUICtrlCreatePic("", 10, 40, 250, 250) GUISetState() ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func GetPos() Local $a $a = GUIGetCursorInfo($Pic1) GUICtrlSetData($x, $a[0]) GUICtrlSetData($y, $a[1]) EndFunc ;==>GetPos Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 (edited) You're losing more time to post than to find how to do it knowing that I almost did it for you (without code). Edited July 16, 2013 by FireFox Link to comment Share on other sites More sharing options...
DW1 Posted July 16, 2013 Share Posted July 16, 2013 FireFox already told you. You already know the coordinates of the control. You know how to get the coordinates of the mouse. The rest is arithmetic. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 (edited) Result: You don't even need to get the cursor coords (with the MouseGetPos function). That was quite hard. #include <GUIConstantsEx.au3> Local $hGUI = 0, $iLabel1 = 0, $aCi = 0, $aCtrlPos = 0 $hGUI = GUICreate("MyGUI") $iLabel1 = GUICtrlCreateLabel("", 10, 10, 100, 13) GUISetState(@SW_SHOW, $hGUI) $aCtrlPos = ControlGetPos($hGUI, "", $iLabel1) ;in case you don't know the control coords While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) $aCi = GUIGetCursorInfo($hGUI) If IsArray($aCi) = 0 Then ContinueLoop GUICtrlSetData($iLabel1, "X: " & $aCi[0] - $aCtrlPos[0] & ", Y: " & $aCi[1] - $aCtrlPos[1]) WEnd GUIDelete($hGUI) Edited July 16, 2013 by FireFox Link to comment Share on other sites More sharing options...
Celtic88 Posted July 16, 2013 Author Share Posted July 16, 2013 AH OK THANK YOU FireFox 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