I'm trying to find a way to get the mouse position relatively to the upper left corner of a control, is there a way to accomplish that?
Once you're in Mouse settings, select Additional mouse options from the links on the right side of the page. In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK. To see it in action, press CTRL.
The cursor position is represented by the line number and the character number and signifies where the next character will be displayed. For example, cursor position 1,1 always indicates the upper-leftmost corner position on the terminal. Cursor position 10,30 indicates the 30th character position on the 10th line.
offset(). left of the parent div container, and calculate the difference from that to the current X and Y coordinates of the mouse cursor. . offset() always refers to the document and not to the parent of the element.
To determine the mouse's current position, we use the statement, pyautogui. position(). This function returns a tuple of the position of the mouse's cursor. The first value is the x-coordinate of where the mouse cursor is.
Call MyControl.PointToClient()
passing Cursor.Position
.
yourControl.PointToClient(Control.MousePosition)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With