unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type TMzSendInput = function(nInputs: Integer; var Inputs: TInput; cbSize: Integer) : integer ; stdcall; TMzInit = function() : integer ; stdcall; const MzSendInput: TMzSendInput = nil; MzInit: TMzInit = nil; var Form1: TForm1; DLLHandle: THandle; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); const DLLNAme = 'MzBot2.dll'; MzInit: TMzInit = nil; begin DLLHandle := LoadLibrary(DLLNAme); if (DLLHandle < HINSTANCE_ERROR) then begin raise Exception.Create(DLLNAme + ' libarary can not be loaded or not found. ' + SysErrorMessage(GetLastError)); end else begin @MzInit := GetProcAddress(DllHandle,'InitMzBot'); @MzSendInput := GetProcAddress(DllHandle, 'AltSendInput'); end; if not (Assigned(MzSendInput) and Assigned(MzInit)) then raise Exception.Create('Function not loaded!'); end; procedure TForm1.Button1Click(Sender: TObject); const Str: string = 'aaaa'; var Inputs: TInput; I: Integer; begin Memo1.SetFocus; for I := 1 to Length(Str) do begin Inputs.Itype := INPUT_KEYBOARD; Inputs.ki.wVk := Ord(UpCase(Str[i])); Inputs.ki.dwFlags := 0; MzSendInput(1, Inputs, SizeOf(Inputs)); Inputs.Itype := INPUT_KEYBOARD; Inputs.ki.wVk := Ord(UpCase(Str[i])); Inputs.ki.dwFlags := KEYEVENTF_KEYUP; MzSendInput(1, Inputs, SizeOf(Inputs)); Application.ProcessMessages; Sleep(80); end; end; end.