Re-incorporate the WaitForInputIdle() function, because MSDN says:

"For example, the parent process should use the WaitForInputIdle function before trying to find a window associated with the child process."
This commit is contained in:
LoRd_MuldeR 2020-09-27 00:53:14 +02:00
parent a9b787a740
commit 9fc973926a

View File

@ -323,8 +323,11 @@ static BOOL signaled_or_failed(const DWORD wait_result)
static BOOL wait_for_process_ready(const HWND hwnd, const HANDLE process_handle, const DWORD process_id)
{
BOOL input_idle = FALSE;
const DWORD ticks_start = GetTickCount();
for (;;)
{
if (input_idle || signaled_or_failed(WaitForInputIdle(process_handle, 125U)))
{
const HWND child_hwnd = find_window_by_process_id(process_id);
if (child_hwnd)
@ -332,7 +335,9 @@ static BOOL wait_for_process_ready(const HWND hwnd, const HANDLE process_handle,
SwitchToThisWindow(child_hwnd, TRUE);
return TRUE;
}
if (signaled_or_failed(WaitForSingleObject(process_handle, 13U)))
input_idle = TRUE;
}
if (signaled_or_failed(WaitForSingleObject(process_handle, 1U)))
{
break;
}