| Store | Cart

Using Pythonwin to poke at Windows apps?

From: Thomas Heller <thel...@python.net>
Thu, 11 Mar 2004 16:08:37 +0100
Henrik.Weber at sdm.de (Henrik Weber) writes:

> Now I've tried this with ctypes:>> from ctypes import *> import win32ui, win32con>> 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)>> class TBBUTTON(Structure):>     _fields_ = (("iBitmap", c_int),>                 ("idCommand", c_int),>                 ("fsState", c_byte),>                 ("fsStyle", c_byte),>                 ("bReserved", c_byte * 2),>                 ("dwData", POINTER(c_long)),>                 ("iString", c_char_p))>> b = TBBUTTON()> f = windll.user32.SendMessageA> TB_GETBUTTON = win32con.WM_USER + 23> print f(t.GetSafeHwnd(), TB_GETBUTTON, 0, byref(b))>>> When I run it the first time I get a return value 1. However the> TBBUTTON structure contains mostly zeroes. Running it again crashes> the Explorer. Even if I open another Explorer the script will crash it> with every subsequent execution until the machine is rebooted.

I had to change the first FindWindow call to this:
  e = win32ui.FindWindow("CabinetWClass", None)
and then it finds an instance of the normal Windows Explorer, on XP pro.

You are correct that the TBBUTTON instance contains all zeros, but it
doesn't crash for me.  Of course I'm not running a released version of
ctypes, instead a patched cvs version.

I cannot see anything that is wrong, it seems that the SendMessage call
doesn't change anything in the TBBUTTON instance.  Can it be that some
messages are not valid over process boundaries?

Thomas

Recent Messages in this Thread
Henrik Weber Mar 09, 2004 02:00 pm
Thomas Heller Mar 09, 2004 03:03 pm
Henrik Weber Mar 11, 2004 01:26 pm
Thomas Heller Mar 11, 2004 03:08 pm
Henrik Weber Mar 15, 2004 12:58 pm
Messages in this thread