Solved

sending text to another program

Posted on 2002-03-21
9
218 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
Comment Utility
What is the statement syntax where you are receiving the error message?
0
 
LVL 5

Expert Comment

by:alanwhincup
Comment Utility
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
Comment Utility
This may also come to interest:

http://www.undu.com\articles/991221b.html
0
 

Author Comment

by:classic_gaming
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
it's just what i wanted :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now