Hi,

Can anyone help me finding an application which can read listbox values of any other window on screen and save the list items either to clipboard or some text file, etc.

This may be done by getting the handle of the window/listbox and then reading the values, etc. I am novice in C programming.

Any help would be greatly appreciated.

Thanks.

Recommended Answers

All 7 Replies

Assuming this is the defaut Windows API listbox..

Step 1: Find a handle to the window containing the list box. [link]
Step 2: Allocate enough space to hold the strings. eg.

int count = (int) SendMessage( listbox, LB_GETCOUNT, 0, 0 );
std::string *items = new string[count];


Step 3: Retrieve those values. eg.

for (int i = 0; i < count; ++i) {
  int itemLength = SendMessage( listbox, LB_GETTEXTLEN, i, 0 );
  char *temp = new char[itemLength];

  SendMessage( listbox, LB_GETTEXT, i, (LPARAM)&temp );
  items[i] = temp;

  delete[] temp;
}

I haven't tested this code, but it should work if you apply it right. Hope this helps.

thanks William, for your response.
Can you pls do me a favor to write a tiny app to read those values. With an interface like, specifying the window handle by some drag/drop thing and then read the list box values, etc.

I am very new to C++ programming and got this as a task :-s

Look forward to your response...

thanks William, for your response.
Can you pls do me a favor to write a tiny app to read those values. With an interface like, specifying the window handle by some drag/drop thing and then read the list box values, etc.

I am very new to C++ programming and got this as a task :-s

Look forward to your response...

That's too much to ask for.

If you're very new to programming, you shouldn't have been set a task like this. I wont do it for you, but what I will do is lead you in the right direction. Start by familiarizing yourself with basic C++, then follow this Win32 API tutorial [link]
There's plenty in there to get you started, after all, that's exactly how I learnt it.

Remember, we aren't here to write code for you.

I haven't tested this code,.

It won't fork for od listbox
.................................

commented: Great remark +0

What? Once again, not helping.
Also, I said

Assuming this is the defaut Windows API listbox.

Well, thanks Williams for guiding me to the tutorial.

Actually I am C# developer and may be I can convert your provided code .net to have it work for me.

OK... this program worked with no errors... But now I want to print the results and "cout << items" is not working..

Could anyone please tell me how to print "std::string" type strings?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.