-
about windows
i have 2 questions about a Windows.
1 - when i use the ShellExecute() for execute a program, how can i wait until the window\program is ready for i use the menu shortcuts with SendInput()?
2 - when we change a window, maybe the window is hided and then is showed, how i can wait until the window\program is ready for change window position?
-
For the #1, I think you need CreateProcess for monitoring the external app.
-
i did something like that without sucess :(
Code:
SHELLEXECUTEINFO lpExecInfo;
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = strFile2.c_str(); // name of file that you want to execute/ print/ or open/ in your case Adobe Acrobat.
lpExecInfo.fMask=SEE_MASK_NOASYNC;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = "open"; // to open program
lpExecInfo.lpParameters = ""; // file name as an argument
lpExecInfo.lpDirectory = NULL;
lpExecInfo.nShow = SW_SHOW ; // show command prompt with normal window size
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ; //WINSHELLAPI BOOL WINAPI result;
ShellExecuteEx(&lpExecInfo);
//wait until a file executed
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
::CloseHandle(lpExecInfo.hProcess);
when i use the GetForegroundWindow(), i get wrong HWND value :(
-
The handle lpExecInfo.hProcess will be signalled until the application you just launched terminates.
The short answer to your questions is that there is no solution. You can either try to wait X minutes or try to monitor the window's message queue to try to figure out when it's ready. There's just no API for this. The best way would, of course, be for the application you start to notify your program when it's ready.