1.如何模拟鼠标左键点击动作
2.
procedure TForm1.Button1Click(Sender: TObject);
var
hwndNotepad : THandle;
begin
hwndNotepad := FindWindow('delphi32',nil); //找不到
//hwndNotepad := FindWindow('notepad',nil);这个可以找到
if hwndNotepad=0 then
begin
ShowMessage('Not found');
Exit;
end;
end;
这段话找不到DELPHI的窗口(其它窗口也不行),但是改成找记事本的窗口句并就可以
2.
procedure TForm1.Button1Click(Sender: TObject);
var
hwndNotepad : THandle;
begin
hwndNotepad := FindWindow('delphi32',nil); //找不到
//hwndNotepad := FindWindow('notepad',nil);这个可以找到
if hwndNotepad=0 then
begin
ShowMessage('Not found');
Exit;
end;
end;
这段话找不到DELPHI的窗口(其它窗口也不行),但是改成找记事本的窗口句并就可以
var
hwndNotepad : THandle;
begin
hwndNotepad := FindWindow('TAppBuilder', nil); // 是TAppBuilder
if hwndNotepad=0 then
begin
ShowMessage('Not found');
Exit;
end
else
ShowMessage('found');
end;
LPCTSTR lpWindowName // pointer to window name
);第一个参数是给出的类名 delphi 的类名是 TAppBuilder。
LPTSTR lpClassName, // address of buffer for class name
int nMaxCount // size of buffer, in characters
);可以得到类名。而 delphi 内定的类名是 TAppBuilder。试试下面的代码:
// 需要放置一个TTimer控件
procedure TForm1.Timer1Timer(Sender: TObject);
var
Pt: TPoint;
CurrentHandle: THandle;
ClassName: array[0..1023] of Char;
begin
GetCursorPos(Pt);
CurrentHandle := WindowFromPoint(Pt);
GetClassName(CurrentHandle, ClassName, Length(ClassName));
Caption := ClassName;
end;