Solved

sending text to another program

Posted on 2002-03-21
9
220 Views
Last Modified: 2010-04-05
hi,

this is a 1/2 continuation from the last question but this involves sending text to another program.

i have edit1.text with data in it. but i'm using the sendmessage command to send data but i have to convert it to a string then i get "not a valid integer" error.

anyone know how to send string to another program?

cheers
classic_gaming
0
Comment
Question by:classic_gaming
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 6886890
What is the statement syntax where you are receiving the error message?
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6886902
Have a look at:

http://www.torry.net/vcl/system/keys/sendkeys.zip
http://www.torry.net/vcl/system/keys/ussendkeys.zip

If this is not what your looking for then do you have the source for the program, or do you know if the program can communicate through DDE or COM etc.

Cheers,

Alan
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6886935
This may also come to interest:

http://www.undu.com\articles/991221b.html
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:classic_gaming
ID: 6887156
it's two exe files one in the program i'm making

and the other is a program i want to get the text from the program i'm making

i dont have any source code because i attempted and i used the sendmessage and it only sends integers

someone said to me use wm_copydata and copydatastruct

here is the code i tried to get working and i know it's wrong

wind := FindWindow('Program',nil);
wm_copydata(wind,copydatastruct(edit1.Text));
//sendmessage(wind,strtoint(edit1.text),0,0);
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6887226
I don't have much time, so I'll suggest you look at Windows Atoms.  That mechanism allows you to send text, not just numbers.
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 6887573
wm_copydata is a windows message :)

hang on, i will have a look now.... will post my results soon.
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6887946
hi,
i guess your wanting something like these:

Function ReadFromNotepad:string;
var h:hwnd;
Text:string;
NumCaracters:integer;
begin
h:=FindWindow('notepad',nil);
h:=FindWindowex(h,0,'edit',nil);
if h<>0 then begin
NumCaracters:=SendMessage(h,wm_getTextLength,0,0);
setlength(text,NumCaracters);
SendMessage(h,wm_getText,NumCaracters+1,Integer(text));
result:=text;
end
else result:='ERROR!';
end;

Procedure WriteToNotepad(what:string);
var h:hwnd;
begin
h:=FindWindow('notepad',nil);
h:=FindWindowex(h,0,'edit',nil);
if h<>0 then SendMessage(h,wm_setText,0,Integer(what))
else showmessage('Error writing to notepad!');
end;

ie:

Writetonotepad(edit1.text);
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6888350
one last (extremely crude) idea...
use SendKeys to send the text.

Note: this only works if the target application has a window.  And you have to activate the target application before you send the characters.
0
 

Author Comment

by:classic_gaming
ID: 6889224
it's just what i wanted :)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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