Solved

How to GetWindowText() without sending

Posted on 1997-09-10
5
565 Views
Last Modified: 2013-12-03
I need to get the window caption of any window in the system. To avoid trouble with calling GetWindowText() on hung applications, I'd like to read the window title directly without sending it WM_GETTEXT. Is this possible?

I know I could use SendMessageCallback() but I wouldn't like to go into all that trouble. Simple tests with Microsoft Spy++ showed that it was capable of reading window titles of hung applications.
0
Comment
Question by:mikkon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1406513
Spy++ works differently. It has a hook that watches the window messages so it can save the information before it hangs. It may also have access to hidden information (undocumented information).
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1406514
Looking at Spy source code - it seems to use GetWindowText.

0
 
LVL 7

Expert Comment

by:faster
ID: 1406515
I think you can still use GetWindowText, to avoid hanging, you can create a number of threads, each thread will can this API, your main thread can monitor the behaviour of them and decide to let a hanging thread terminate and create a new one.  Of course, this is somehow complex to implement.
0
 
LVL 1

Author Comment

by:mikkon
ID: 1406516
Messing with several threads would be much more difficult than using SendMessageCallback().

I tested this with Spy++ (no source available, I guess?) so that I hung my application and then started Spy. It was capable of reading the title of my hung application so it probably uses some undocumented features. :-(
0
 
LVL 3

Accepted Solution

by:
byang earned 100 total points
ID: 1406517
Just use SendMessageTimeout().

Still, you should launch threads. If you use a timeout value of 1 second, and there're 3 hang programs having a total of 15 windows, your app. could timeout 15 seconds.

BTW, just because an application is hung doesn't mean calling GetWindowText() on it will hang.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question