Finding and closing a window based on its contents

I know that you can close a window by using the SENDMESSAGE function but is there a way to find a window based on its contents and not by its title?

Let's say I have two windows on screen. One that contains the word "Hello to all human beings" and another that contains "Good morning to you". Is there a function that would allow me to find the first by searching with the word "beings"? I repeat, the words are NOT in the title bar but in the window itself.

Thank you.
LucDesaulniersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
That really depends on how the words are being displayed.  If they are being rendered graphically then the answer is no (unless you resort to OCR techniques).  If they are in labels, then depending on the language the application was developed in, the answer is maybe.  If the text is in a standard control such as a textbox, then it is possible to enumerate all the windows in an app and query them for their text value using API calls.

Could you elaborate a little more on the type of apps these are and how the text you want to search for is displayed?

~IM
0
aelatikCommented:
Are you talking about windows from 1 kind of application ? Or can it be different applications ?
0
Bob LambersonSoftware EngineerCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LucDesaulniersAuthor Commented:
Thanks. I'll try that.
Just to clear things up, here is my exact situation.

My company is using a mission-critical system to publish invoices and uses Acrobat Distiller to convert them into PDF files. Problem is that Distiller cannot run as a service to whenever something is wrong with the file to be converted, a message will pop on screen and Distiller will wait for someone to click on the OK button to resume working. You can guess that this can cause big problems when that happens in the middle of the night.

Right now we have instructed the night shift operator to go and check on the server from time to time and click on the OK button should he see an error message on screen but that can lead to human error.

I first wrote a VB program to close a window based on its title but that won't do the trick because both Distiller and the error message box share the same title. So if I were to run my program both the error message and Distiller would end up being shut down which would only make the problem worse.

The error message box always contains the words "ERROR OPENING FILE...". So I would like to write a program that would search for windows containing these words and shut them down.

I will look at th supplied thread and let you know if it does the trick for me.

Thanks.
0
Bob LambersonSoftware EngineerCommented:
using API to enum all the windows and test for the contents is the answer and IM and I both provided that information. I think the points should be split.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.