MerkurAlex Posted February 9, 2008 Posted February 9, 2008 I need a quick and simple way to figure out where the mouse is inside of a window not like mousegetpos() [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]
GaryFrost Posted February 9, 2008 Posted February 9, 2008 #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hwnd = GUICreate("Example", 200, 200) Local $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", 641) DllStructSetData($tpoint, "Y", 459) GUISetState(@SW_SHOW) Sleep(1000) _WinAPI_ScreenToClient($hwnd, $tpoint) MsgBox(0, "_WINAPI_ScreenToClient Example", "Screen Cordinates of 641,459 is x,y position of client: " & @LF & _ "X: " & DllStructGetData($tpoint, "X") & @LF & _ "Y: " & DllStructGetData($tpoint, "Y") & @LF) EndFunc ;==>_Main SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
erezlevi Posted February 9, 2008 Posted February 9, 2008 hi, what is the difference between client coordinated and screen coordinates?
BrettF Posted February 9, 2008 Posted February 9, 2008 Client is the actual window co-ords. If you look at these examples, it might clear it up a little more. #AutoIt3Wrapper_au3check_parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; _Win_API Examples ; Function: _WinApi_ #include <WinAPI.au3> Opt('MustDeclareVars', 1) Example_Internal() Func Example_Internal() Local $hwnd = GUICreate("Example", 200, 200) Local $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", 641) DllStructSetData($tpoint, "Y", 459) GUISetState(@SW_SHOW) Sleep(1000) _WinAPI_ScreenToClient($hwnd, $tpoint) MsgBox (0, "_WINAPI_ClientToScreen Example", "Screen Cordinates of client's x,y position: 100,160 is: " & @LF & _ "X: " & DllStructGetData($tpoint, "X") & @LF & _ "Y: " & DllStructGetData($tpoint, "Y") & @LF) EndFunc ;==>Example_Internal #AutoIt3Wrapper_au3check_parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; _Win_API Examples ; Function: _WinApi_ #include <WinAPI.au3> Opt('MustDeclareVars', 1) Example_Internal() Func Example_Internal() Local $hwnd = GUICreate("Example", 200, 200) Local $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", 100) DllStructSetData($tpoint, "Y", 160) GUISetState(@SW_SHOW) Sleep(1000) _WinAPI_ClientToScreen($hwnd, $tpoint) MsgBox (0, "_WINAPI_ClientToScreen Example", "Screen Cordinates of client's x,y position: 100,160 is: " & @LF & _ "X: " & DllStructGetData($tpoint, "X") & @LF & _ "Y: " & DllStructGetData($tpoint, "Y") & @LF) EndFunc ;==>Example_Internal Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
erezlevi Posted February 9, 2008 Posted February 9, 2008 hi, first Thanks, now lets see If i got it: you mean client coordinates in the Examples are where is the client resides from the X,Y declared values? meaning that -28,-54 result is where the client is away from 641,459 ? (the X of the client is away from 641 in -28 pixles, and the Y of client is away -54 from 459) right? if so, how will it help the guy with his question about where the mouse is? this solution gives where the GUI is from X,Y or not?
BrettF Posted February 9, 2008 Posted February 9, 2008 hi, first Thanks,now lets see If i got it: you mean client coordinates in the Examples are where is the client resides from the X,Y declared values? meaning that -28,-54result is where the client is away from 641,459 ? (the X of the client is away from 641 in -28 pixles, and the Y of client is away -54 from 459) right?if so, how will it help the guy with his question about where the mouse is? this solution gives where the GUI is from X,Y or not?If _ScreenToClient resides in the co-ords of the window + witdth and height. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
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