NEED: A way to hook or somehow be notified of any new window handle that is created while my application is running. I am monitoring for certain windows and would greatly appreciate a way to listen to any new window that is created. The application is written in VB.NET but I am open to solutions that combine technologies.
Background and Detail:
I have a very simple automation application that is designed to look for certain problem windows or dialog boxes and click a button that the user has predefined. I have already gotten ALL the information about the target window and target controls (Class Names, Text, etc....) the problem is the way that I am having to monitor for these is to constantly get all the top level windows and then search through all the children etc. This is a huge waste of valuable system resources.
I have tried to look up how to create a global hook in VB.NET and have found many things but nothing seems up the ally that I need. All I need is the window handle (I have the APIs working to get the text and class name etc.. for any handle I feed them, its just the subscribing to the windows messages that is causing me the biggest headache. to any window created or destroyed. I plan on creating a collection of these to hold onto for helping me target things but I need a way to do it quickly without having to search every single window and work my way down.