Solved

How to GetWindowText() without sending

Posted on 1997-09-10
5
554 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

785 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