Solved

sending text to another program

Posted on 2002-03-21
9
223 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 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
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!

 

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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