flasht
asked on
Handle under mouse pointer.
How do i get handle of control under mouse pointer (of other application of course) and how do i enable this control if its disabled by this handle? (Like Greatis WinDowse can do)
There is a small and smart tool, called Showin that can get the hwnd of a control, show/hide or enable/disable it, etc.
It can be downloaded here: www.foundstone.com/resources/forensics.htm
If you keep to doing this in Delphi, some useful Winapi functions:
Functions connected to mouse cursor
GetCursorPos(var Pt:TPoint);
SetCursorPos(x, y:integer);
Simulating mouse click at the position of the mouse, etc.
mouse_event(MOUSEEVENTF_LE FTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LE FTUP, 0, 0, 0, 0);
Getting window handle at a point:
WindowFromPoint(coordinate s: TPoint);
ChildWindowFromPoint(paren t_hwnd: THandle, relative_coordinates: TPoint);
Getting window/widget position to calculate relative coordinates:
GetWindowRect(hwnd:THandle , var rect:TRect);
Enable/disable window:
EnableWindow(hwnd: THandle, enable: boolean);
You'll find more information about these functions in MSDN.
It can be downloaded here: www.foundstone.com/resources/forensics.htm
If you keep to doing this in Delphi, some useful Winapi functions:
Functions connected to mouse cursor
GetCursorPos(var Pt:TPoint);
SetCursorPos(x, y:integer);
Simulating mouse click at the position of the mouse, etc.
mouse_event(MOUSEEVENTF_LE
mouse_event(MOUSEEVENTF_LE
Getting window handle at a point:
WindowFromPoint(coordinate
ChildWindowFromPoint(paren
Getting window/widget position to calculate relative coordinates:
GetWindowRect(hwnd:THandle
Enable/disable window:
EnableWindow(hwnd: THandle, enable: boolean);
You'll find more information about these functions in MSDN.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But it still doesnt work as WinDowse... It gets the handle of the window but it does not show handle of component on that window...
Try to get the handle by a small freeware program called Showin
http://baixaki.ig.com.br/site/detail2516.htm
If it can't get the control's handle with Showin, I think you can't get it at all.
By the way, certain controls don't have hwnd (e.g. TSpeedButton in Delphi).
http://baixaki.ig.com.br/site/detail2516.htm
If it can't get the control's handle with Showin, I think you can't get it at all.
By the way, certain controls don't have hwnd (e.g. TSpeedButton in Delphi).
The code i gave you does get the handle of some components like buttons, radio buttons, forms.
You need different code for menus...even WinDowse cant get menus.
You need different code for menus...even WinDowse cant get menus.
(May have to strip it a bit)
Var
Mpos: DWord;
X,Y: Word;
P: Tpoint;
Wnd: Hwnd;
Begin
Mpos:=getmessagepos();
Y:=hiword(Mpos);
X:=loword(Mpos);
P.x:=X;
P.Y:=Y;
Wnd:=WindowFromPoint(P);
//Wnd = window's handle do was you please.
End;