4
Answers

WindowCapture

Aleksandar Ilioski

Aleksandar Ilioski

12y
2.2k
1
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


Answers (4)