Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Obtain data from other windows

Posted on 1998-04-19
15
Medium Priority
?
199 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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