How can I view the text of items in a Listbox using inspect.exe in a Windows application?

29 Views Asked by At

When I use inspect.exe to inspect a Listbox in a Windows application, I cannot see the text of the items in the Listbox. There is no text in the name, text value, or pattern value. Is the text of the items hidden or something else?

import win32gui
import win32con 
# Find the handle of the main window 
app_Class = "TkTopLevel" window_handle =win32gui.FindWindow(app_Class, None) 

if window_handle == 0: print("Cannot find handle from window") 
exit() 
# Find the handle of the listbox within the main window control_class = "TkChild" listbox_handle =win32gui.FindWindowEx(window_handle, None, control_class, None) 
if listbox_handle == 0: print("Cannot find handle from listbox in window") 
exit() 
# Get the count of items in the listbox item_count =win32gui.SendMessage(listbox_handle, win32con.LB_GETCOUNT, 0, 0)
 print("Count of items in listbox is:", item_count) 
# Iterate over each item in the listbox and print its text for index in range(item_count): 
# Get the length of the item's text item_text_length = win32gui.SendMessage(listbox_handle, win32con.LB_GETTEXTLEN, index, 0) 
# Create a buffer to hold the item's text item_text_buffer = win32gui.PyMakeBuffer(item_text_length + 1) 
# Get the item's text and store it in the buffer win32gui.SendMessage(listbox_handle, win32con.LB_GETTEXT, index, item_text_buffer) # Convert the buffer to a string item_text = item_text_buffer[:item_text_length] 
# Print the item's text print("Item text", index, ":", item_text) 

""" Note : When run code, it is get me this result : Count of items in listbox is: 0 """

The Listbox in main window contain on 5 items.

0

There are 0 best solutions below