I have an application that calls createprocessasuser (e.g. notepad.exe) which works fine.
The problem is that the window is being created behind the currently focused window. I have tried messing with the process start-up flags etc. but was unable to find a suitable configuration to get it to work.
Now I am thinking I need to simulate a click on it? I have code to locate a window (using window name) and click on a button which works but I want click on the frame of the created process as I am not sure what the name may be (no control over what process name they type in).
You need to grab the HWND of the application you have launched and then align the thread for this application with the thread of your application so that you can call to SetForeGroundWindow on the third party app: