|
Why not place it in a separate thread? All the thread function needs to do is a continual loop that calls FindWindow(), closes the window if found, and sleeps for 1 second. Preferably, it would also check some flag so that, as your program exits, it could simply set that flag and the thread would terminate within 1 second.
As an aside, I'm not convinced that the best way to implement a "Download Blocker" is to simply close windows that are associated with a download. The workaround would be a little program that runs more frequently and sets the window label to something different --- or, even better, closing down your "Download Blocker". A better way would be to prevent programs from opening a network connection. Of course, that stops all email clients and browsers.
|