Код | var h:cardinal; i:integer; begin h:=FindWindow('CabinetWClass','Панель управления'); if h=0 then begin ShellExecute(0,nil,'control.exe',nil,nil,0); i:=20; repeat h:=FindWindow('CabinetWClass','Панель управления'); sleep(100); Application.ProcessMessages; until (h<>0) or (i=0); if h=0 then ShowMessage('Не дождался окна')else while IsWindow(h) and not Application.Terminated do begin Sleep(100); Application.ProcessMessages; end; if Application.Terminated then messagebox(0,'Надоело ждать','',0) else ShowMessage('Окно закрыто'); end else begin ShowMessage('Окно открыто без нас'); SetForegroundWindow(h); end; end;
|
|