Board index » delphi » Getting TEXT from an Edit Control in a Window of another application

Getting TEXT from an Edit Control in a Window of another application


2005-02-25 10:22:01 AM
delphi149
I am trying to use (in DELPHI 2005) the GetWindowText(Handle, @Buffer,
SizeOf(Buffer) - 1) function to get the text info from an Edit Control of a
window in ANOTHER application. (I used the GetClassName(), function to help
identify the Windiow(s) I need to work with in a call with the
EnumChildWindows() function).
However, I read in the C++ Builder Help and at the MERS search database that
you can't use GetWindowText() to retrieve the text data of an Edit
Control of a window in ANOTHER application. And others suggest using other
approach (in DELPHI) like - SendMessage(Handle, WM_GETTEXT,
SizeOf(Buffer) - 1, Integer(@Buffer)), BUT that ALSO return a BLANK value in
the "Buffer" at ALL times.
I also tried using the DefWindowProc(Handle, WM_GETTEXT, SizeOf(Buffer) - 1,
Integer(@Buffer)) directly in a CALLBACK function I designed for used in the
EnumChildWindows() function, and that seems to FAIL as well.
Can anyone demonstrate (with some code samples) EXACTLY what must be done in
DELPHI (preferably) and/or in C++ Builder to retrieve the TEXT DATA of any
Edit Control of a Window in ANOTHER application?
Looking forward to your reply.
________________________
Alister (Francisco) John
XXXX@XXXXX.COM
 
 

Re:Getting TEXT from an Edit Control in a Window of another application

Quote
Can anyone demonstrate (with some code samples) EXACTLY what must be done
in DELPHI (preferably) and/or in C++ Builder to retrieve the TEXT DATA of
any Edit Control of a Window in ANOTHER application?
is it your own application or someother one that you can not change the code
of?
if it is yours why don't you use WM_COPYDATA message to exchange data? (if
interested in a ready-made solution that uses WM_COPYDATA for local machine
communication and is also TCP/IP enabled if you want cross-machine
communication, see "Plugs" at my website URL below)
-----
George Birbilis (XXXX@XXXXX.COM)
Microsoft Most Valuable Professional
MVP J# for 2004 & 2005
www.kagi.com/birbilis
--------------
 

Re:Getting TEXT from an Edit Control in a Window of another application

Hello Mr. George Birbilis:
Thank you very much for your reply.
Actually what I need to do is to be able to simply READ the TEXT data of any
(and all) Edit Control or Edit Drop Down List box contained
in ANY Window that the CURRENT Focus on my Desk Top. The Window with the
CURRENT focus can be of ANY application
running on my PC (like Word, Internet Explorer, Excel, etc, etc).
I already know how to determine the Window that has the CURRENT focus (the
Top Window normally), but after I determine that, I need to
iterate all the "child" windows of that FOREGROUND window and "capture" the
TEXT of any Edit or Edit Dropdown List box control.
I am doing the following...
sysHWND := GetForegroundWindow;
EnumChildWindows(sysHWND, @TChildCBProc, LPARAM(lpr));
Then in my "TChildCBProc" function, I am doing the following...
function TChildCBProc(CBHdl: HWND; lpr: LPARAM): WordBool;
var
cBuffer: array[0..256] of char;
begin
fillchar(cBuffer,SizeOf(cBuffer),#0);
// GetWindowText(CBHdl, cBuffer, SizeOf(cBuffer)-1);
// DefWindowProc(CBHdl, WM_GETTEXT, SizeOf(cBuffer)-1, LPARAM(@cBuffer));
SendMessage(CBHdl, WM_GETTEXT, SizeOf(cBuffer)-1, LPARAM(@cBuffer));
frmMain.Memo1.Lines.Add('CHILD TEXT = '+StrPas(cBuffer));
Result := True;
end;
The "EnumChildWindows" I called ,does seem to iterate through the several
"child"
windows that MAY be in the FOREGROUND window. BUT, regardless to whether
I use SendMessage(..) or DefWindowProc(..) or GetWindowText(...), the
"cBuffer"
variable I passed to these functions NEVER gets filled with any value!
Please help!!
Thank you for your time.
___________________
Alister (Francisco) John
XXXX@XXXXX.COM
"George Birbilis" <XXXX@XXXXX.COM>writes
Quote
>Can anyone demonstrate (with some code samples) EXACTLY what must be done
>in DELPHI (preferably) and/or in C++ Builder to retrieve the TEXT DATA of
>any Edit Control of a Window in ANOTHER application?

is it your own application or someother one that you can not change the code
of?

if it is yours why don't you use WM_COPYDATA message to exchange data? (if
interested in a ready-made solution that uses WM_COPYDATA for local
machine communication and is also TCP/IP enabled if you want cross-machine
communication, see "Plugs" at my website URL below)

-----
George Birbilis (XXXX@XXXXX.COM)
Microsoft Most Valuable Professional
MVP J# for 2004 & 2005
www.kagi.com/birbilis
--------------