Solved

sending text to another program

Posted on 2002-03-21
9
226 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
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 46

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 46

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 46

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

617 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