Teraz mam inny problem,
Znalazłem w internecie kod do symulacji wciskania klawiszy
procedure jump(Key : Cardinal; KeyUp : boolean);
var
Input : TagINPUT;
begin
Input.Itype := INPUT_KEYBOARD;
Input.ki.wVK := Key;
Input.ki.wScan := MapVirtualKey(Key, 0);
if Key in [VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_HOME,
VK_END, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE] then
begin
Input.ki.dwFlags := KEYEVENTF_EXTENDEDKEY;
end
else
begin
if KeyUp = False then
begin
Input.ki.dwFlags := 0;
end
else
begin
Input.ki.dwFlags := KEYEVENTF_KEYUP;
end;
end;
Input.ki.time := 0;
SendInput(1, Input, SizeOf(Input));
end;
A w timera daje:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
jump(Ord('6'), False);
sleep(5);
jump(Ord('6'), True);
end;
function LowLevelKeyboardProc(nCode : Integer; wParam : Integer; lParam : Integer) : Integer; stdcall; export;
var
Hook : PKBDLLHOOKSTRUCT;
begin
Hook := Pointer(lParam);
case nCode of
HC_ACTION :
begin
Form1.Timer1.Enabled := (GetForeGroundWindow = Form1.Handle)
and (Hook.vkCode = VK_LCONTROL) and (Hook.Flags = 0);
end;
end;
Result := CallNextHookEx(HKHook, nCode, wParam, lParam);
end;
Lecz to nie działa, chodzi o to że gdy trzymam Lewy Kontrol to program wciska 6 w windowsie ogólnie, nie w danym oknie, I reakcja na Ctrl jest tylko w oknie programu, gdy testowałem na showmessage w timerze to tylko w programie działało a generowanie 6 w ogóle nie działą w timerze ani w procedurze a jak wpisze w formcreate to działa. ja tego nie rouzmiem.