A unit called SndKey32.pas included on the Delphi installation CD (\Info\Extras\SndKey32.pas), makes it easy to simulate keyboard usage. This unit includes two routines that simulate popular VB routines: Sendkeys and AppActivate. SendKeys takes a PChar as its first parameter and a boolean as its second, like so:
SendKeys('KeyString', Wait) ;
where KeyString is a string of key names and modifiers that you want to send to the current input focus and Wait is a boolean variable or value that indicates whether SendKeys should wait for each key message to be processed before proceeding.
AppActivate also takes a PChar as its only parameter, like so:
AppActivate('WindowName') ;
where WindowName is the name of the window that you want to make the current input focus.
Example syntax: SendKeys('abc1{left}def{end}456{left 4}ghi', True) ;
results in a string "abcdefghi123456" being sent to active window (control with focus)
Delphi tips navigator:
» How to track a user's idle time
« How to call the View Source dialog in WebBrowser

