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
Solved

Obtain data from other windows

Posted on 1998-04-19
15
194 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…

791 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