Link to home
Start Free TrialLog in
Avatar of mikkon
mikkon

asked on

How to GetWindowText() without sending

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.
Avatar of Tommy Hui
Tommy Hui

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).
Looking at Spy source code - it seems to use GetWindowText.

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.
Avatar of mikkon

ASKER

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. :-(
ASKER CERTIFIED SOLUTION
Avatar of byang
byang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial