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);这句,想起到单击按钮的作用,却是怎么也不行,但我单独另做了一个窗体,上面放个按钮调用却非常好用,不知道这个?
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);这句,想起到单击按钮的作用,却是怎么也不行,但我单独另做了一个窗体,上面放个按钮调用却非常好用,不知道这个?
SendMessage(hbut, WM_LBUTTONDOWN, 0, 0);//按下
SendMessage(hbut, WM_LBUTTONUP, 0, 0);//松开
把一个命令改成两个竟然就可以了,怪,难道wm_click完成不了一个单击动作吗?
竟然可以了,难道bm_click完成不了一次鼠标单击的事件吗?