Tja,
das Programm startet, hat den Focus, der Anwender muss eine Datei laden, die wird bearbeitet, dann muss der Anwender sie woandes speichern.
Ergo benutze ich das Fenster.
Wenn ich jetzt prüfe ob das Fenster bereits vorhanden ist via WaitforInputIdle muss ich das
Handle der Anwendung haben. Oder? Gut:
Delphi-Quellcode:
function processExists(exeFileName: string): Boolean;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
Result := False;
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
begin
Result := True;
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
Delphi-Quellcode:
RunAndWaitShell(XMLPAth + '
emperormapper.exe','
',1);
If ProcessExists('
emperormapper.exe')
then
begin
WaitforInputIdle(FSnapshotHandle,10000);
HANDLE := FindWindow(
Nil,'
EmperorMapper');
MoveWindow(
HANDLE, 600, 600, 400, 400, True);
end;
Ich werde jetzt nicht ganz schlau aus dem ProcessExists. Wird da geprüft ob der Process existiert bis er existiert?
Jedenfalls geht es so auch nicht.
geldis