Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create a small (non-gui) launcher application that will call the new program for you (I know, that's what you've called the hard solution) and then schedule this launcher on the task scheduler.</p> <p>This launcher application would have to create de process (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx" rel="nofollow">CreateProcess function</a>), and then get the Window Handle from the pID... with the window handle you can use SetForegroundWindow to do what you need, or call other functions for things like maximize, etc.</p> <p>Since you tagged delphi, I'm posting a possible delphi implementation of that.</p> <pre><code>function WindowFromPID(pID: Cardinal; VisibleWindow: Boolean): Cardinal; type TProcData = record pID: Cardinal; pHandle: Cardinal; VisibleWindow: Boolean; end; var wPData: TProcData; function EnumProc(Handle: HWND; var pProcData: TProcData): Bool; stdcall; var pID: DWORD; begin Result := True; if pProcData.VisibleWindow then if not IsWindowVisible(Handle) then Exit; GetWindowThreadProcessId(Handle, @pID); if pID = pProcData.pID then begin if GetWindow(Handle, GW_OWNER) = 0 then begin pProcData.pHandle := Handle; Result := false; end; end; end; begin wPData.pHandle := 0; wPData.pID := pID; wPData.VisibleWindow := VisibleWindow; EnumWindows(@EnumProc, Integer(@wPData)); while (wPData.pHandle = 0) do begin Sleep(50); EnumWindows(@EnumProc, Integer(@wPData)); end; Result := wPData.pHandle; end; procedure RunAndGetWindowHandle(const FileName, Params: String; const WindowState: Word): Cardinal; var SUInfo: TStartupInfo; CmdLine: String; ProcInfo: TProcessInformation begin CmdLine := '"' + Filename + '"' + Params; FillChar(SUInfo, SizeOf(SUInfo), #0); with SUInfo do begin cb := SizeOf(SUInfo); dwFlags := StartF_UseShowWindow; wShowWindow := WindowState; end; if not CreateProcess(Nil, PChar(CmdLine), nil, nil, False, Create_New_Console Or Normal_Priority_Class, nil, PChar(ExtractFilePath(Filename)), SUInfo, ProcInfo) then raise Exception.Create('Error running process'); if WaitForSingleObject(ProcInfo.hProcess, 50) &lt;&gt; WAIT_TIMEOUT then raise Exception.Create('Error running process!'); CloseHandle(ProcInfo.hThread); while Result = 0 do begin Sleep(50); Result := WindowFromPID(ProcInfo.dwProcessId, true); end; end; ... var WindowHandle: Cardinal; begin WindowHandle := RunAndGetWindowHandle("powerpnt.exe", " /s", SW_SHOWNORMAL); SetForegroundWindow(WindowHandle); end; </code></pre> <p>Hope that's what you need.. sorry if it's not.</p> <p>Best Regards.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload