Using Pythonwin to poke at Windows apps?

Thomas Heller theller at python.net
Tue Mar 9 10:03:50 EST 2004


Henrik.Weber at sdm.de (Henrik Weber) writes:

> Hello all,
>
> I'm trying to read information about widgets from running instances of
> win32 applications. My current victim is the Explorer on a XP box. I'm
> trying to access the menu bar. On XP this is not a standard menu but a
> toolbar. So far I can retrieve a PyCWnd object with win32ui:
>
>>>> e = win32ui.FindWindow("ExploreWClass", None)
>>>> w = win32ui.FindWindowEx(e, None, "WorkerW", None)
>>>> w = win32ui.FindWindowEx(w, None, "ReBarWindow32", None)
>>>> t = win32ui.FindWindowEx(w, None, "ToolbarWindow32", None)
>>>> t = win32ui.FindWindowEx(w, t, "ToolbarWindow32", None)
>>>> hex(t.GetSafeHwnd())
> '0x602d8'
>>>> print t
> object 'PyCWnd' - assoc is 01275A88, vi=<None>, notify=0,ch/u=0/0,
> mh=0, kh=0
>
> I know that t now refers to a ToolbarWindow32 widget but seemingly
> win32ui doesn't. Is there a way to get a PyCToolbar object from this?

No idea.

> Or do I have to continue by sending messages? I tried sending a
> TB_GETBUTTON message with win32gui.SendMessage, using a Python array
> to reserve some memory for the TBBUTTON structure, but so far I have
> only succeeded in crashing the Explorer. What would be the right way
> to send a message that needs some memory to put the results into?

If you go this way, ctypes is what you need.  And Simon Bruning has
written a series of articles which also might be helpful:

http://www.brunningonline.net/simon/blog/archives/000652.html

Thomas





More information about the Python-list mailing list