Solved

sending text to another program

Posted on 2002-03-21
9
221 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

821 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