Starting a process and then modifying its size and position

tbfreefall

Member
Joined
Oct 17, 2007
Messages
11
Programming Experience
Beginner
I am using process.start() to start an application from withing mine. I need to be able to modify is size/position properties.
 
Some applications work like that and there may be nothing you can do about it. Sometimes the process you start will exit without creating a main window and the window you see actually belongs to a different process. This will also happen if you run a single-instance application more than once.
 
I think it may be a problem with the WaitForInputIdle() not working. The application i am testing with is just a web browser and should not have a problem with what you said. If i just put "notepad.exe" in for the process it works. I think the WaitForInputIdle() is not working and the only reason notepad will work and the web browser will not is that notepad is ready almost instantly (does not require a wait) and the browser is not ready instantly.
 
I also commented out the WaitForInputIdle() line and it works with notepad. I would have to say that this line is definitely not doing what i think it should be doing.
 
WaitForInputIdle waits until the process is ready to receive input, which may be before a main window handle is available. To confirm that your process definitely does expose a main window handle try just sleeping your thread for about 10 or 15 seconds before trying to get it. If there is one to get then you know it will be available by then. If you still get Zero then you know that that process simply doesn't expose a main window handle. If it does then you can just add a loop that will sleep repeatedly until a handle is available. You should apply a timeout to that though because if a browser window is already open then opening a new Web page will create a new tab within the existing main window, NOT create a new one.
 
I learned something new there, I thought that's what WaitForInputIdle was for, i'm pretty sure that's even what some of the documentation said its use is for. Just goes to show that you can't believe everything you read!!:)
 
Yeah, i actually came across that windows function before going on this forum. I remember trying it and having it not do what i expected. I think that we are using it correctly here. Now i need to find a function that actually does this. It is exactly what i need because some of the apps that are going to be started take some time to load so there is no way to know how long to wait without something like this.
 
Back
Top