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的窗口(其它窗口也不行),但是改成找记事本的窗口句并就可以

解决方案 »

  1.   

    procedure TForm1.Button7Click(Sender: TObject);
    var
      hwndNotepad : THandle;
    begin
      hwndNotepad := FindWindow('TAppBuilder', nil);   // 是TAppBuilder
      if hwndNotepad=0 then
      begin
        ShowMessage('Not found');
        Exit;
      end
      else
        ShowMessage('found');
    end;
      

  2.   

    HWND FindWindow(    LPCTSTR lpClassName, // pointer to class name
        LPCTSTR lpWindowName  // pointer to window name
       );第一个参数是给出的类名 delphi 的类名是 TAppBuilder。
      

  3.   

    那这个TAPPBUILDER在哪里能找到呢?我是在进程里面查找的
      

  4.   

    int GetClassName(    HWND hWnd, // handle of window
        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;