943,937 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 888
  • C++ RSS
Oct 2nd, 2009
3

Reading Listbox values of other window

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codecodile is offline Offline
5 posts
since Oct 2009
Oct 2nd, 2009
1

Re: Reading Listbox values of other window

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.
C++ Syntax (Toggle Plain Text)
  1. int count = (int) SendMessage( listbox, LB_GETCOUNT, 0, 0 );
  2. std::string *items = new string[count];
Step 3: Retrieve those values. eg.
C++ Syntax (Toggle Plain Text)
  1. for (int i = 0; i < count; ++i) {
  2. int itemLength = SendMessage( listbox, LB_GETTEXTLEN, i, 0 );
  3. char *temp = new char[itemLength];
  4.  
  5. SendMessage( listbox, LB_GETTEXT, i, (LPARAM)&temp );
  6. items[i] = temp;
  7.  
  8. delete[] temp;
  9. }
I haven't tested this code, but it should work if you apply it right. Hope this helps.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 3rd, 2009
1

Re: Reading Listbox values of other window

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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codecodile is offline Offline
5 posts
since Oct 2009
Oct 3rd, 2009
2

Re: Reading Listbox values of other window

Click to Expand / Collapse  Quote originally posted by codecodile ...
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.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 3rd, 2009
0

Re: Reading Listbox values of other window

I haven't tested this code,.
It won't fork for od listbox
.................................
Last edited by marco93; Oct 3rd, 2009 at 7:03 am.
Reputation Points: -76
Solved Threads: 14
Junior Poster
marco93 is offline Offline
132 posts
since Apr 2008
Oct 3rd, 2009
0

Re: Reading Listbox values of other window

What? Once again, not helping.
Also, I said
Quote ...
Assuming this is the defaut Windows API listbox.
Last edited by William Hemsworth; Oct 3rd, 2009 at 8:38 am.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 3rd, 2009
1

Re: Reading Listbox values of other window

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codecodile is offline Offline
5 posts
since Oct 2009
Dec 4th, 2010
0
Re: Reading Listbox values of other window
OK... this program worked with no errors... But now I want to print the results and "cout << items[i]" is not working..

Could anyone please tell me how to print "std::string" type strings?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rohan1020 is offline Offline
9 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: undeclared identifiers.
Next Thread in C++ Forum Timeline: Assigning a string a value





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC