Solved

Obtain data from other windows

Posted on 1998-04-19
15
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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
 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

734 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