Jump to content

ControlGetPos then send mouse to it.


MHz
 Share

Recommended Posts

I considered to locate a controls position with ControlGetPos. Then to move the mouse to that control, but co-ordinates are not received correctly? I also find that the array returned may be reversed at times i.e ('x, y' or 'y, x'). Swapping arrays does not help to reverse?

Or maybe my understanding of using this function is incorrect?

Sample

; Mousemove to Calculator - button 7
Opt("MouseCoordMode", 0)
WinActivate("Calculator")
$POS = ControlGetPos("Calculator", "", "Button5")
MsgBox(0, "Button 7", "Position is: " & $POS[0] & ", " & $POS[1])
WinActivate("Calculator")
MouseMove($POS[0], $POS[1])
Link to comment
Share on other sites

MouseMove only supports absolute screen coordinates.

Opt("MouseCoordMode", 1) tells the ControlGetPos to report relative coordinates, so you need to change the MouseCoordMode to zero.

Edit: Yeah, what Larry said :)

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • Developers

controls are placed in the "client" area of a window. You will need to adjust Mouse coords by

- getting the Window size...

- getting the window's Client size

- subtract 1/2 of the difference in widths for X adjustment

- subtract the difference in height and add 1/2 the difference in width for Y

I'm lazy now, but will elaborate later if someone else doesn't

LAr.

<{POST_SNAPBACK}>

check out this post for a scriptlet : http://www.autoitscript.com/forum/index.ph...indpost&p=11831

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

To find a control on a window, i need to do a series of calculations to locate the control?

ControlGetPos is not used for this purpose? I do not recognize any other function that may interact with ControlGetPos? It's existence depends on retrieving the position and size of a control relative to it's window?

Does ControlGetPos have a reason to exist?

Link to comment
Share on other sites

Guest BL@(K-R34P3R

That's what I think too, because ControlClick can click in a minimized window, but only at the current mouse position, as far as I know, it cannot click on specific coordinates unless in window or maximized. Could be useful to retrieve the coordinates of the mouse so that when you maximize the window you will know where it will be.

Link to comment
Share on other sites

That's what I think too, because ControlClick can click in a minimized window, but only at the current mouse position, as far as I know, it cannot click on specific coordinates unless in window or maximized. Could be useful to retrieve the coordinates of the mouse so that when you maximize the window you will know where it will be.

<{POST_SNAPBACK}>

The coordinates that ControlGetPos seems not useful for mouse functions.

If you want to know where the mouse is, try MouseGetPos.

Link to comment
Share on other sites

  • Developers

To find a control on a window, i need to do a series of calculations to locate the control?

ControlGetPos is not used for this purpose? I do not recognize any other function that may interact with ControlGetPos? It's existence depends on retrieving the position and size of a control relative to it's window?

Does ControlGetPos have a reason to exist?

<{POST_SNAPBACK}>

The Control position info is relative the Windows client area and the mouse functions are relative the the whole window including its frame...

ControlGetPos could be use together with ControlMove.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@ Larry you win, lol, but...

If what you say about themes, making a window larger or smaller, would that have an effect on mouse functions and others. Would they fail as the reliance on the window being the same size?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...