procedure TForm1.Button9Click(Sender: TObject);
Var
Men :HMenu;
Hnd,HndDialog,HndControl,HndAsc,HndBtn :HWnd;
HndMen,HndSMen :HMenu;
StrClass :PChar;
StrBase :string;
IdBtn,idMen :integer;
begin
Hnd:=FindWindow(nil, 'Конфигуратор - 2345');
if Hnd <>0 then begin
windows.SetForegroundWindow(Hnd);
HndMen:=GetMenu(Hnd);
HndSMen:=GetSubMenu(HndMen,1);
idMen:=GetMenuItemID(HndSMen,6);
if idMen<>0 then begin
PostMessage(Hnd,WM_COMMAND,idMen,0);
HndDialog:=0;
HndControl:=0;
HndBtn:=0;
HndAsc:=0;
IdBtn:=0;
While HndDialog=0 do HndDialog:= FindWindow(nil, 'Открыть файл конфигурации');
if HndDialog<>0 then begin
StrClass:='Edit'+#0;
HndControl:=FindWindowEx(HndDialog,0,StrClass,'');
if HndControl<>0 then begin
StrBase:='D:\md\zik2345\1Cv7.MD';
Sleep(1000);
SendMessage(HndControl, WM_Settext,0,Integer(StrBase));
SendMessage(HndDialog,WM_Command,MakeWParam(1,$0f),HndControl);
while HndAsc=0 do HndAsc:= FindWindow(nil, 'Конфигуратор');
if HndAsc<>0 then begin
while HndBtn=0 do HndBtn:=FindWindowEx(HndAsc,0,'Button','&Да');
if HndBtn<>0 then begin
IdBtn:=GetDlgCtrlID(HndBtn);
if IdBtn<>0 then begin
SendMessage(HndAsc,WM_Command,MakeWParam(IdBtn,BN_CLICKED),HndBtn);
end;
end;
end;
end;
end;
end;
end;
end; |