|
-
Jun 2nd, 2008, 12:30 PM
#13
Re: Help making a program that captures windows/programs into itself!
I tested Notepad and MsPaint and they seem to work fine, but for explorer you probably need to do a similar type of loop as in my module, wait till the PID and handle are not = 0, and if not found in 1 or 2 secs then exit the loop and show a not found message. This is really a hack, and a really busy or really slow PC may not always work as expected, you may want to look at other APIs to find out when the window is ready instead of just waiting in a loop.
I see one possible problem here, if no handle is found the LockWindowUpdate wasn't reset.
Code:
If mWnd = 0 Then
LockWindowUpdate False
MsgBox "Error getting handle to the program"
Exit Sub
End If
One thing you really need to consider is the closing of the programs, you really shouldn't assume the handle you are passing is the one you need or a valid one, and if more then one program was open then you need to close all of them, you probably want to store the Handles or the PIDs in an array after a program opens successfully, then when your program is about to exit you would loop through the array and if the Handle/PID is found running then destroy it or whatever, tho if it were me I'd probably send the program a WM_Close or WM_Quit message instead of trying to kill the process or destroy the window.
You may also need to check how many programs are running every so often and if the count changes check your PID array against those PIDs, cause what happens if I close an app inside your program then open 100 different programs outside your program and it just so happens to have the same handle or PID in your array?, you could end up closing the wrong program(s).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|