Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SendKeys in DELPHI ?

2,016 views
Skip to first unread message

Mario Brocchi

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

I wonder if anybody knows the corresponding of the VB5 command
"Sendkeys" in Delphi 3.0.

Petar Banicevic

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Mario Brocchi wrote in message <35741FF7...@siosistemi.it>...


>I wonder if anybody knows the corresponding of the VB5 command
>"Sendkeys" in Delphi 3.0.

What SendKeys does in VB ???

Alex Kaufman

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Dear Mario,

Use the keybd_event function.

regards,
Kaufman Alex.

Peter Below

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

> I wonder if anybody knows the corresponding of the VB5 command
> "Sendkeys" in Delphi 3.0.

Mario,

for short key sequences you can use the keybd_event API function:

Procedure PostVKey( vkey: Byte );
Begin
keybd_event( vkey, MapVirtualkey(vkey, 0), 0, 0 );
keybd_event( vkey, MapVirtualkey(vkey, 0), KEYEVENTF_KEYUP, 0 );
End;

Procedure PostText( hw: HWND; Const S: String );
Var
i: Integer;
Begin
For i:= 1 To Length(S) Do
PostVkey( Ord(UpCase(S[i]))) ;
End;

Key events manufactured this way go the window with focus. For more complex
things a WH_JOURNALPLAYBACK hook is recommended, an example can be found on

http://www.inprise.com/delphi/papers/winAPI/part2.html


Peter Below (TeamB) 10011...@compuserve.com)


Erik B. Berry

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Petar Banicevic wrote:
> What SendKeys does in VB ???

It sends a set of keystrokes to another application. For a good
Delphi example, see http://www.fredsterware.com/delphi.htm.

Erik

Richard Simpson

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Take a look at WM_Char and WM_KeyDown in the Win32Help file that comes with
Delphi.

To send one of those messages to your control, use the Delphi Perform
method. Example:

Memo1.Perform(WM_KeyDown, VK_F2, 0) sends your memo the F2 (function) key.

(One mistake I keep making is forgetting to qualify Perform with the
particular control, in which case nothing will appear to happen.)

0 new messages