Код:
(****************************************
* *© Пархоменко Евгений Владимирович *
* сайт: http://decoding.narod.ru *
* e-mail: decoding@narod.ru *
* 28.07.2003г. *
* *
* Информация о посторонних окнах *
****************************************)
unit WndInfoFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Panel1: TPanel;
Label1: TLabel;
LabelLeft: TLabel;
LabelTop: TLabel;
Label2: TLabel;
LabelWidth: TLabel;
LabelHeight: TLabel;
LabelName: TLabel;
LabelClass: TLabel;
LabelHandle: TLabel;
Label3: TLabel;
LabelParentHandle: TLabel;
LabelParentName: TLabel;
LabelParentClass: TLabel;
Label4: TLabel;
LabelParentLeft: TLabel;
LabelParentTop: TLabel;
Label5: TLabel;
LabelParentWidth: TLabel;
LabelParentHeight: TLabel;
LabelPosX: TLabel;
LabelPosY: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
Wnd: HWND; // Hahdle найденного окна
Pos: TPoint; // Позиция курсора
Rect: TRect; // Координаты окна
buff: array[0..255] of char; // Буфер
WndText: string; // Текст окна
NameClass: string; // Класс окна
begin
// Получаем позицию курсора
GetCursorPos( Pos );
// Получаем Handle окна под курсором
Wnd := WindowFromPoint( Pos );
GetWindowRect( Wnd, Rect );
GetWindowText( Wnd, buff, SizeOf( buff ) );
WndText := StrPas( buff );
GetClassName( Wnd, buff, SizeOf( buff ) );
NameClass := StrPas( buff );
// Выводим координаты курсора
LabelPosX.Caption := 'X: ' + IntToStr( Pos.X );
LabelPosY.Caption := 'Y: ' + IntToStr( Pos.Y );
LabelHandle.Caption := 'Handle: ' + IntToStr( Wnd );
LabelName.Caption := 'Name: ' + WndText;
LabelClass.Caption := 'Class: ' + NameClass;
LabelLeft.Caption := 'Left = ' + IntToStr( Rect.Left );
LabelTop.Caption := 'Top = ' + IntToStr( Rect.Top );
LabelWidth.Caption := 'Width = ' + IntToStr( Rect.Right - Rect.Left );
LabelHeight.Caption := 'Height = ' + IntToStr( Rect.Bottom - Rect.Top );
// Получаем Handle родительского окна
Wnd := GetParent( Wnd );
GetWindowRect( Wnd, Rect );
GetWindowText( Wnd, buff, SizeOf( buff ) );
WndText := StrPas( buff );
GetClassName( Wnd, buff, SizeOf( buff ) );
NameClass := StrPas( buff );
LabelParentHandle.Caption := 'ParentHandle: ' + IntToStr( Wnd );
LabelParentName.Caption := 'ParentName: ' + WndText;
LabelParentClass.Caption := 'ParentClass: ' + NameClass;
LabelParentLeft.Caption := 'ParentLeft = ' + IntToStr( Rect.Left );
LabelParentTop.Caption := 'ParentTop = ' + IntToStr( Rect.Top );
LabelParentWidth.Caption := 'ParentWidth = ' + IntToStr( Rect.Right - Rect.Left );
LabelParentHeight.Caption := 'ParentHeight = ' + IntToStr( Rect.Bottom - Rect.Top );
end;
end.
С помощью этого кода узнаю hwnd пытаюсь кликнуть ничего не выходит
открываю spy++ и вижу что хендл моего окна совсем другой как это понять?