Solved

Obtain data from other windows

Posted on 1998-04-19
15
192 Views
Last Modified: 2013-12-03
How can I programmatically obtain the content of an edit box that is from other process, without using copy to clip board. I wish to obtain this data from the edit box so that it is available inside my program and I will be able to use it.
0
Comment
Question by:waimun
  • 4
  • 4
  • 3
  • +3
15 Comments
 
LVL 6

Expert Comment

by:WxW
ID: 1298586
You use the GetWindowText(HWND,LPSTR,int) for example :
char TheText[1000];
::GetWindowText(hWndEdit,TheText,1000);

To find the handle to the edit button , you need to use FindWindow . If the edit control is a child to another Window , use the FindWindow to find the handle to the other Window , and then Use GetDlgItem to get the handle to the edit box . Or you can use FindWindowEx to direct search for the edit box

0
 

Author Comment

by:waimun
ID: 1298587
Thanks, but I've tried this way and it do work out. Do not forget that the edit box is from another process, and if you try to obtain the caption using GetWindowText, it will return blank of NULL. I believe that this is due to the reason that Window95 prohibit of data sharing from different process. But anyway, thanks you for trying to help....
0
 
LVL 22

Expert Comment

by:nietod
ID: 1298588
You must have made a mistake.  You can use GetWindowText() on windows from other processes.
0
 
LVL 6

Expert Comment

by:WxW
ID: 1298589
Correct . Maybe you use the wrong Window class name or HWND value
I was not sure about my first answer , but nietod has the same opinion .
0
 
LVL 1

Expert Comment

by:_Zaphod
ID: 1298590
Unless of course that edit box has a password style.
0
 

Author Comment

by:waimun
ID: 1298591
Yes, of course we can use GetWindowText for other process, but have you try it out? It seems to me that this only work for normal windows, like dialog box, button etc. It will not work for edit box even if it is not in a passowrd style. To test it out, may be you can try using SPY++ that came with Window SDK. It will report the captions of most of the windows but "Blank" for edit box. If anyone can show me a method for this, I will reward him for 100 pts. What if the edit box is in password style?
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1298592
Try sending a EM_GETLINE message instead
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 11

Expert Comment

by:alexo
ID: 1298593
waimun, GetWindowText() doesn't work.
However, SendMessage(hwnd, WM_GETTEXT, (WPARAM)(sizeof buff), (LPARAM)buff) works just fine.
Which is strange, because they're supposed to be the same...


0
 

Author Comment

by:waimun
ID: 1298594
thanks RONSLOW & alexo for your helps. yes i agree with u alexo that it is strange that SendMessage works. in fact i used the code that u attached in the comment straight away, an it work! So as a token for u i will give u 20 pts. for free, since RONSLOW answer it first. got to be fair. I will raise an empty question for u to answer to get the 20 pts.
Cheers!!!!
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1298595
Good to see someone being fair with points to all those who contribute :-)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1298596
Thanx waimun.  Nice to feel appreciated :-)
I was a bit confused at first when I saw a question comprised of "thank you"...

BTW, Ron's answer is correct but it will only give you one line of thext, which is fine if you have a one-line edit box but a bit of a problem otherwise.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1298597
BTW: RONSLOW is short for Roger ONSLOW, rather than Ron Slow

WM_GETTEXT sounds better

BTW: According to the documentation on GetWindowText

"This function cannot retrieve the text of an edit control in another application."

So there you go.

0
 

Author Comment

by:waimun
ID: 1298598
Anyway, thanks to u 2 guys!
Cheers!!!
0
 
LVL 11

Expert Comment

by:alexo
ID: 1298599
Sorry Roger, I stand corrected.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1298600
Thats all right Mr Exo, first name Al :-)

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now