Hello
I have some problem that bother me for few days..
I need to do the following..
start a process (with some arguments), find the window of the process, take a picture of that window, and kill the process
and I need to repeat this operation X times..
I can start the process, using user32: find its main handle, get the window size, so I know the size of the image, set the window position to 0,0, and make it topMost, and than copyFromScreen metod to capture that image.. from 0,0, to size of the window..
So it look like everything is ok, but there is one problem that I can't solve..
when the process is started, I notice that to use the setWindowPos native function, some time should pass so I use Thread.sleep(x seconds), but
that time is different on every system.. and that is the problem.. I must know how long delay to make on every system.. and I can't let big unnecceary delay because the process repeats hundreds of times.. and every millisecond is important,
Please if You have some solution, I will be happy to hear..
Thank You in advance
Loading
VulpesPosted Jul 16, 2012, 10:40 AM
Aleksandar IlioskiPosted Jul 16, 2012, 11:16 AM
1. The main window handle is still IntPtr.Zero.
give me Idea..
and Yes, probably that was the problem..
so I make it to check every 0.2 seconds if IntPtr!=0
It looks like it works..
Yes probably the problem with SetWindowPos, was that IntPtr=0, at the moment I do that..
so 0.2 seconds step is I think reasonable enough..
Thank You for the question, that helps me figure out the problem
Thank You
Aleksandar IlioskiPosted Jul 16, 2012, 10:09 AM
doesn't work..
the process is opera mobile emulator..
other solution is to use sendMessage, and change the url, instead of starting the process over and over.. and
I will wait once, but that also doesn't work..
using Spy++ I try to find details about the process, like className .. and it says invalid window..
so I probably can't use sendMessage too..
VulpesPosted Jul 16, 2012, 9:51 AM
http://msdn.microsoft.com/en-us/library/8d7363e2.aspx
That should ensure that it's safe to use SetWindowPos on any system.