Wywoływanie:
C := PChar(' '); //Podanie znaku do klikania, czyli spacja
Push(C);
Kod:
type
TKomunikatLista = class(TList)
public
destructor Destroy; override;
end;
var
KomIlosc : Word ;
Hook : Integer;
Komunikat : TEventMsg;
KomunikatLista : TKomunikatLista ;
destructor TKomunikatLista.Destroy;
var
I: Word;
begin
for I := 0 to Count - 1 do
Dispose(PEventMsg(Items[i]));
inherited Destroy;
end;
procedure ZrobKomunikat(Klawisz: byte; Komun: Cardinal);
var
Kom: PEventMsg;
begin
New(Kom);
with Kom^ do
begin
message := Komun;
paramL := Klawisz;
paramH := MapVirtualKey(Klawisz, 0);
time := GetTickCount;
hwnd := 0;
end;
KomunikatLista.Add(Kom);
end;
function Play(Code: integer; wParam, lParam: Longint): Longint; stdcall;
begin
case Code of
hc_Skip:
begin
inc(KomIlosc);
if KomunikatLista.Count<=KomIlosc then
begin
UnhookWindowsHookEx(Hook);
KomunikatLista.Free;
end
else
Komunikat := TEventMsg(KomunikatLista.Items[KomIlosc]^);
Result := 0;
end;
hc_GetNext:
begin
PEventMsg(lParam)^ := Komunikat;
Result := 0
end;
else
Result := CallNextHookEx(Hook, Code, wParam, lParam);
end;
end;
procedure Push(s:string);
var
X: Integer;
begin
KomunikatLista := TKomunikatLista.Create;
for X := 1 to Length(S) do
begin
ZrobKomunikat(vkKeyScan(s[x]), wm_KeyDown);
ZrobKomunikat(vkKeyScan(s[x]), wm_KeyUp);
KomIlosc := 0;
end;
Komunikat := TEventMsg(KomunikatLista.Items[0]^);
Hook := SetWindowsHookEx(wh_JournalPlayback, Play, hInstance, 0);
end;
Jak coś to tu masz projekt.