ad...@genesisware.de wrote:
> Thanks for you answer. The handle is unfortunately from another process.
>
> This is a piece of code I have found on the web that works great to get the 
> values of a list from another process. I have marked the part where I want to 
> select a list item:

Yes, this is what it takes.  Do you see how nasty this is?  You are
injecting code and data into another processes memory space.  Sheesh.

> def readListViewItems(hwnd, column_index=0):
> ...
>       for item_index in range(num_items):
>               win32gui.SendMessage(hwnd, LVM_GETITEMTEXT, item_index, pLVI)
>               target_buff = ctypes.create_string_buffer(4096)
>               ReadProcessMemory(hProcHnd, pBuffer, 
> ctypes.addressof(target_buff), 4096, p_copied)
>               item_texts.append(target_buff.value)
>               
>               if target_buff.value == "something":
>                       # HERE THE list item should be selected, if the value 
> of the list item is something
>                       #
>                       #
>                       #
>                       pass

You will need to send an LVM_GETITEM message to fetch the item's
attributes.  Then, you'll change the items "state" to make it selected. 
Then you will send an LVM_SETITEM to make your changes permanent.  Note
that the LVM_GETITEM can also fetch the text of the item.  You'll want
to read the description of those messages carefully.

Remember that you will have to use ReadProcessMemory and
WriteProcessMemory to access the structure.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to