We help IT Professionals succeed at work.
Get Started

Get window handles of new windows as they are created in VB.NET application.

Last Modified: 2016-06-19
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.
Watch Question
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE