unit dvmacro;
interface
uses winprocs, wintypes;

    function PlayInit (nMsg: integer): boolean;  far;
    function PlayStart: boolean; far;
    function PlayIsActive: boolean; far;
    procedure playKey (key: char; delay: longint); far;
    procedure playAltKey (key: char; delay: longint);  far;
    procedure playVirtKey (key: byte; comCtl, comShift, comAlt: boolean; delay: longint); far;
    procedure playString (s: string; delay: longint); far;
    procedure playInsertKeyEvent (command: word; key: word;  delay: longint); far;
    procedure playMouse (command, x, y: word; delay: longint);  far;
    procedure keyboardClick (letra: char);
    procedure keyboardAlt (letra: char);
    procedure mouseClick (x, y: integer);

implementation

function PlayInit (nMsg: integer): boolean;           external 'HKBMOUSE' index 2;
function PlayStart: boolean;                          external 'HKBMOUSE' index 3;
function PlayIsActive: boolean;                       external 'HKBMOUSE' index 4;
procedure playKey (key: char; delay: longint);        external 'HKBMOUSE' index 5;
procedure playAltKey (key: char; delay: longint);     external 'HKBMOUSE' index 6;
procedure playVirtKey (key: byte; comCtl, comShift, comAlt: boolean; delay: longint);
                                                      external 'HKBMOUSE' index 7;
procedure playString (s: string; delay: longint);     external 'HKBMOUSE' index 8;
procedure playInsertKeyEvent (command: word; key: word;  delay: longint);
                                                      external 'HKBMOUSE' index 9;
procedure playMouse (command, x, y: word; delay: longint);
                                                      external 'HKBMOUSE' index 10;
procedure keyboardClick (letra: char);
var
    codLetra: longint;
begin
    codLetra := (oemKeyScan (ord(letra)) and $ffff) shl 8 +
                  vkKeyScan (ord(letra));

    playInit (30);
    playInsertKeyEvent (WM_KEYDOWN, codLetra, 1);
    playStart;
    while  playIsActive do;

    playInit (30);
    playInsertKeyEvent (WM_KEYUP, codLetra, 1);
    playStart;
    while  playIsActive do;
end;

procedure keyboardAlt (letra: char);
begin
    playInit (30);
    playAltKey (letra, 1);
    playStart;
    while  playIsActive do;
end;

procedure mouseClick (x, y: integer);
var rectg: TRECT;
begin
    playInit (30);
    playMouse (WM_MOUSEMOVE, x, y, 1);
    playStart;
    while  playIsActive do;

    playInit (30);
    playMouse (WM_LBUTTONDOWN, x, y, 1);
    playStart;
    while  playIsActive do;

    playInit (30);
    playMouse (WM_LBUTTONUP, x, y, 1);
    playStart;
    while  playIsActive do;
end;

end.