Sign in to follow this  
Followers 0
Maches

Get Mouse Pos by Title button in program

7 posts in this topic

Hello,

Is there possible in AutoIT to get Position of mouse by title button in X program?  

For example I run notepad and I have menu corner.. and I would like to get x,y position of mouse from edit  or help... .

Can I get it by x function ? I would like to create an automate program to myself what I need but I won't writing position manual of mouse, because its not working properly.

Thanks in advence, and sorry for my bad english

 

Share this post


Link to post
Share on other sites



55 minutes ago, Maches said:

Can I get it by x function ? I would like to create an automate program to myself what I need but I won't writing position manual of mouse, because its not working properly.

It's possible, but you have to write your own integrated Infotool, WinGetPos, ControlGetPos may be helpfull.

Share this post


Link to post
Share on other sites

Ye buut how to do this. Maybe somebody have some code and can share with me?

Share this post


Link to post
Share on other sites
 
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position x, y and size (width and height) of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetPos.
    Local $aPos = ControlGetPos($hWnd, "", "Edit1")

    ; Display the position and size of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

When I use this function I have return 0,0.....

 

When I use this function i have return 0 and 0

Share this post


Link to post
Share on other sites

Have you read the help to ControlGetPos? I don't think so, also you haven't read the help to WinGetPos.

Didn't you know the different from a Window and a Control?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yes I read this.

 

I use  ControlGetPos ( "title", "text", controlID )  to get X,Y cordinates of X button by using info tool (AutoIT v3 Window Tool)..

But this function returns me wrong X,Y position...

And also when I moving my Window to other positions,  the program returns the same cordinates x,y as before

Edited by Maches

Share this post


Link to post
Share on other sites
#include <WinApi.au3>

Global $hWnd

Run("Notepad.exe")
Do
    $hWnd = WinGetHandle("Untitled - Notepad")
Until (WinExists($hWnd))

Global $tMousePoint = _WinAPI_GetMousePos(True, $hWnd)

MsgBox("", "Mouse Position", "X and Y position of the mouse relative to client area of Notepad: " & $tMousePoint.x & ", " & $tMousePoint.y)

_WinApi_GetMousPos gives you the x and y position of the mouse relative to the client area of the program. In notepad the client area would be the edit part of notepad, excluding the menu

Share this post


Link to post
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
Sign in to follow this  
Followers 0