delphi点击外部程序的按钮
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
h, i: HWND;
j, k : HWND;
l, m : HWND;
begin
h := FindWindow(nil, '搜狗拼音输入法 5.2正式版 安装');
while(h<>0) do
begin
i := FindWindowEx(h,0,'Button','下一步(&N) >');
SendMessage(i, BM_CLICK, 0, 0);
sleep(100);
memo1.Lines.Add('action 1') ;
j := FindWindowEx(h,0,'Button','我接受(&I)');
SendMessage(j, BM_CLICK, 0, 0);
sleep(500);
memo1.Lines.Add('action 2') ;
end;
end;
end.
这是代码,前几个按钮都能够正常点击,为什么最后一个不行?望高手赐教。。。