现在两个exe应用程序A和B
在A程序中点击按纽后向B程序中发送一段字符串并且触发B中的Buttonclink事件
该怎么做呢?
在A程序中已可以取得B中用到的控件了,代码如下:
function EnumChildWndProc(AhWnd:LongInt;
AlParam:lParam):boolean;stdcall;
var
WndClassName: array[0..254] of Char;
WndCaption: array[0..254] of Char;
begin
GetClassName(AhWnd,wndClassName,254);
GetWindowText(aHwnd,WndCaption,254);
with form1.memo1 do
begin
lines.add( string(wndClassName));
lines.add( string(wndCaption));
lines.add('-------');
end;
result:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hWnd:LongInt;
begin
memo1.Lines.Clear;
Memo1.Lines.Add(Edit1.Text+' 有如下控件类名称');
hWnd:=FindWindow(nil,pchar(Edit1.Text));
if hWnd<>0 then
begin
EnumChildWindows(hWnd,@EnumChildWndProc,0);
end
else MessageBox(self.handle,'没找到该窗口句柄','提示',0);end;接下来该怎么向B程序发送一段字符串并触发Buttonclick事件呢?
请各位指教!
在A程序中点击按纽后向B程序中发送一段字符串并且触发B中的Buttonclink事件
该怎么做呢?
在A程序中已可以取得B中用到的控件了,代码如下:
function EnumChildWndProc(AhWnd:LongInt;
AlParam:lParam):boolean;stdcall;
var
WndClassName: array[0..254] of Char;
WndCaption: array[0..254] of Char;
begin
GetClassName(AhWnd,wndClassName,254);
GetWindowText(aHwnd,WndCaption,254);
with form1.memo1 do
begin
lines.add( string(wndClassName));
lines.add( string(wndCaption));
lines.add('-------');
end;
result:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hWnd:LongInt;
begin
memo1.Lines.Clear;
Memo1.Lines.Add(Edit1.Text+' 有如下控件类名称');
hWnd:=FindWindow(nil,pchar(Edit1.Text));
if hWnd<>0 then
begin
EnumChildWindows(hWnd,@EnumChildWndProc,0);
end
else MessageBox(self.handle,'没找到该窗口句柄','提示',0);end;接下来该怎么向B程序发送一段字符串并触发Buttonclick事件呢?
请各位指教!
发送单击消息给 Button :SendMessage(按钮句柄, WM_LBUTTONDOWN, 0, 0);
Sleep(10);
SendMessage(按钮句柄, WM_LBUTTONUP, 0, 0);