I need a code, which will be constantly pressing the arrow up button when I am holding the ctrl button on keyboard - to simulate ctrl (pressed until i release it) + arrow up. The code I got so far:
function LowLevelKeybdHookProc(nCode, wParam, lParam : integer) : integer; stdcall;
var
info : ^KeybdLLHookStruct absolute lParam;
lpChar : word;
kState : TKeyboardState;
s:string;
i:integer;
inputArray: array[0..3] of TInput;
begin
result := CallNextHookEx(kHook, nCode, wParam, lParam);
with info^ do
case wParam of
wm_keydown : begin
GetKeyboardState(kState);
if GetKeyState(VK_CONTROL) = 0 then
begin
inputArray[0].Itype := INPUT_KEYBOARD;
inputArray[0].ki.wVk := VK_UP;
inputArray[1].Itype := INPUT_KEYBOARD;
inputArray[1].ki.wVk := VK_UP;
inputArray[1].ki.dwFlags := KEYEVENTF_KEYUP;
SendInput(length(inputArray), inputArray[0], sizeof(TInput));
end;
end;
end;
end;
I tried to make it myself, but something doesnt work properly - it's like a strange mouse and keyboard glitch, which keeps the arrow button and sometimes even right mouse click pressed and could be fixed only when clicking ctrl+alt+delete. I would appreciate any help. Thank you.
This one seems to be working, but with some kind of delay:
It's like I really got to hold the control pressed for a while. I need something with a much faster reaction.