Mengirim teks ke Notepad


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
edt1: TEdit;
procedure edt1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.edt1Change(Sender: TObject);
var
wnd: HWND;
i: Integer;
s: string;
begin
// mencari handle Notepad

wnd := FindWindow(‘notepad’, nil);
if wnd <> 0 then
begin
wnd := FindWindowEx(wnd, 0, ‘Edit’, nil);

// Teks yang akan dikirim
s := Edt1.Text;
// menulis teks pada Notepad
for i := 1 to Length(s) do
SendMessage(wnd, WM_CHAR, Word(s[i]), 0);
// simulasi tombol enter
PostMessage(wnd, WM_KEYDOWN, VK_RETURN, 0);
// simulasi tombol spasi
PostMessage(wnd, WM_KEYDOWN, VK_SPACE, 0);
end;
end;

end.

TransCODE Software

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s