Hi I am desperately trying to get the text from a chat window.

My idea was to use win32gui.GetWindowText(). I wrote a program to display any text with win32gui.GetWindowText() by iterating over all past and previous handles and as deep into each handle as there are children. Basically I tried to go trough the z-Axis. Without success.

I also tried to take a picture of the chat and use OCR (tesseract) to reconstruct the text. It seems like the problem is the pictures taken with PIL’s GrabImage() don’t have high enough DPI to work with tesseract.

Also if I use a program such as AutoIt Window info, it does not show the chat message as text. I wonder it is possible to “hide” this chat text.

Any ideas? Help is greatly appreciated!

schuerm

I think I may have what you are looking for, if the text you want to get is contained in an 'Edit' handle. Go to google and search for winGuiAuto.py and when you find it save it to your computer.

Doing something like this will get the text from a notepad window:

from winGuiAuto import *

notepad=findTopWindow(wantedText='Untitled - Notepad')
for x in dumpWindow(notepad):
     if x[2]=='Edit':
          win_text=x[0]

print getEditText(win_text)[0]

Of course you will have to modify this for your program.

Thanks for the answer. I think I know where the problem is. I can't get the text with getEditText and the handle. I found trough winspector that the class of the chat window is Internet Explorer_Server. Any idea how to get the text from an the Internet Explorer_Server class window?

Thanks for the winGuiAuto lib. very helpful

schuerm

Can you tell me what the software is that you are trying to get the chat from? It sounds from the class name that it may be a chat embedded in Internet Explorer or something like that? If I can open up the software on my computer, I might be able to figure it out.

This article has been dead for over six months. Start a new discussion instead.