[python-win32] (again) get Window Title encoding

Creative iNFiNiTY roche.maxime at creativeinfinity.fr
Mon Feb 28 13:22:53 CET 2011


here is some code to get the window title:

            hwnd = win32gui.GetForegroundWindow()
            # we want the desktop window
            objid = pyAA.Constants.OBJID_WINDOW
            # get the object
            ao = pyAA.AccessibleObjectFromWindow(hwnd, objid)
            pr= ao.GetProcessAndThreadID()
            processes = win32process.EnumProcesses()
            for pid in processes:
                    if pid in pr:
                        handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid)
                        processactif=win32process.GetModuleFileNameEx(handle, 0)

	    WindowTitle=ao.Name
                 
another code:
	import win32gui
	w=win32gui
	w.GetWindowText (w.GetForegroundWindow())


and i need to get the encoding of the title for internalisation purpose,
does anyone know how to get it ?
the automatic charset recognition in python ," chardet" don't work for every charset,
if i can take it by the process that will be great.
Thanks

Roche Maxime
Creative iNFiNiTY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110228/dc98c34a/attachment.html>


More information about the python-win32 mailing list