Maches Posted March 1, 2016 Share Posted March 1, 2016 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 Link to comment Share on other sites More sharing options...
AutoBert Posted March 1, 2016 Share Posted March 1, 2016 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. Link to comment Share on other sites More sharing options...
Maches Posted March 1, 2016 Author Share Posted March 1, 2016 Ye buut how to do this. Maybe somebody have some code and can share with me? Link to comment Share on other sites More sharing options...
Maches Posted March 1, 2016 Author Share Posted March 1, 2016 #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 Link to comment Share on other sites More sharing options...
AutoBert Posted March 1, 2016 Share Posted March 1, 2016 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? Link to comment Share on other sites More sharing options...
Maches Posted March 30, 2016 Author Share Posted March 30, 2016 (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 March 30, 2016 by Maches Link to comment Share on other sites More sharing options...
InunoTaishou Posted March 30, 2016 Share Posted March 30, 2016 #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 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