[python-win32] PyCListCtrl.GetItem() across processes
Michael Maurer
mjmaurer at yahoo.com
Wed May 11 05:46:23 CEST 2005
Hello,
I am trying to read the contents of a CListCtrl. The control is in a window
owned by a non-python process. I can get pretty close but ultimately get a
failure from PyCListCtrl.GetItem(). I think it's because the python layer is
passing a pointer from its own address space to a different process when it
asks the CListCtrl to respond to GetItem().
Specifically, I have:
* Process A, non-python process, has window with CListCtrl control
* Process B, python process, executes the following steps:
- win32gui.EnumWindows to find the window in process A
- win32gui.EnumChildWindows to find the list control in that window
- win32ui.CreateWindowFromHandle to wrap the control's handle with a
PyCListCtrl object
- PyCListCtrl.GetItemCount() works fine, as do other getters and setters that
don't require pointers
- PyCListCtrl.GetItem() fails with the message: "GetItem failed"
The error seems to be coming from win32ctrlList.cpp PyCListCtrl_GetItem()
function, which allocates a local LV_ITEM on the stack and then passes the
address to CListCtrl->GetItem().
I found this article that explains how to use the VirtualAllocEx(),
ReadProcessMemory() and WriteProcessMemory() functions to do something very
similar to what I want, but in C:
http://www.codeproject.com/threads/int64_memsteal.asp
So my questions are:
1. is my diagnosis of the problem correct?
2. is there any way to do a cross-process GetItem() from python?
3. more important, is there another way to do what I want from python, which is
to read the contents of a CListCtrl contained in a window owned by another
process?
Thanks,
Michael M
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
More information about the Python-win32
mailing list