I have an application (the controling application) that controls another application (the Target application).
The target application is some other Windows-based application that I cannot control directly other than through the UI. My users would like to automate certain tasks and the controlling application's design goal is to carry out tasks for the user.
I have managed to use C# and P/Invoke to find the application's window, enumerate over the controls, click buttons, and set/clear checkboxes. All of this is great but now I'm stuck.
The target application has a ListBox whose contents move around based on certain criteria. I know that a certain item is somewhere in the ListBox control but I cannot find a way to (a) locate the item and (b) select the item.
I have done some research and have found a number of Windows messages that should work to get a ListBox's item count and even listing of items - but I cannot get that to work. I also need a way to extract the position of the item in the list so that I can simulate a click event.
Sounds complicated? Perhaps. I managed to figure most of this stuff out by inspecting Windows messages using Spy++ but now I need some more help.
You can get full points for answering this question by providing sample code that reads through a ListBox that resides in another application (a commerical application that you don't have the source code for), locates a particular item in the list, and selects the item. The sample must be in C# and use P/Invoke. I'm not at all concerned about finding the application's window or ListBox control - I already know how to do that, so if your sample does not include that but I can get it to work, you'll get full points.
Thanks in advance,