Solved

Obtain data from other windows

Posted on 1998-04-19
15
193 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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