unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  formhd,htxt,hbut,hmemo1,hmemo:hwnd;
implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
hbutton1,hm:hwnd;
lp:LPTSTR;
ykt:integer;
begin
     repeat
     htxt:=findwindowex(0,formhd,nil,'搜索引掣');
     hbut:=findwindowEX(htxt,0,nil,'搜索(&S)');
    until hbut<>0;
    hmemo:=findwindowex(htxt,0,'TComboBox',nil);//getwindow(hmemo1,GW_CHILD);
    hm:=GetNextWindow(hmemo,GW_HWNDNEXT);
    if hm<>0 then
     begin
       edit1.SelectAll;
       edit1.CopyToClipboard;
       sendmessage(hm,WM_SETTEXT,0,0);
       sendmessage(hm,WM_PASTE,0,0);
       if hbut<>0 then
       SendMessage(hbut,BM_CLICK,0,0);
     end;
end;end.程序原码在这里了,上面的都好用,只是到了SendMessage(hbut,BM_CLICK,0,0);这句,想起到单击按钮的作用,却是怎么也不行,但我单独另做了一个窗体,上面放个按钮调用却非常好用,不知道这个?

解决方案 »

  1.   

    // 模拟按键
      SendMessage(hbut, WM_LBUTTONDOWN, 0, 0);//按下
      SendMessage(hbut, WM_LBUTTONUP, 0, 0);//松开
      

  2.   

    TO:xzhifei(星级饭桶(抵制日货)·飞) 
    把一个命令改成两个竟然就可以了,怪,难道wm_click完成不了一个单击动作吗?
      

  3.   

    TO:xzhifei(星级饭桶(抵制日货)·飞)
    竟然可以了,难道bm_click完成不了一次鼠标单击的事件吗?
      

  4.   

    你是要浏览器里面的按钮被点击吧!如果是,当然使用BM_CLICK不行了