Link to home
Start Free TrialLog in
Avatar of ZaSz
ZaSzFlag for Canada

asked on

Sending key to another app (like writing to notepad)

For example, write something to notepad.

I have no idea how to do it.

Please no dll thing, only a procedure like WriteNotepad(Sentence: String) or something like that.
Thanks
Avatar of -TM-
-TM-

Heres how to send text to a yahoo messenger IM Window.

procedure TForm1.Send(S:String);
var
IM,IM2:Integer;
begin
IM:=FindWindow('IMClass',nil);
IM2:=findwindowex(IM, 0, PChar(lowercase('RICHEDIT')),nil);
Sendmessage(IM2,wm_Settext,0,LongInt(S));
SendMessage(IM2,wm_keydown,13,1);
end;
Avatar of ZaSz

ASKER

With the FindWindow, what do I have to put in it to find Notepad?

And why do you search 2 windows?
i think this work in not operational, because the notepad not a socket exe file.
you can create a file and then open it with notepad
example create readme.txt in c:\test directory
and write this instruction for open this file:
ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\test\readme.txt'), nil, SW_SHOW);



ASKER CERTIFIED SOLUTION
Avatar of Slavak
Slavak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial