Вниз
Скачать: CL | DM;

Problema s GetKeyboardState   Найти похожие ветки 

 
Сергей К. ©   (2004-11-11 17:22) [0]

Я внутри Low Level Keyboard Hook во время его срабатывания
узнаю нажаты командные клавиши (ctrl/shift/alt/win) с помощью
этой функции (см. ниже),она взависимости от состояния
этих клавиш возвращает код (0 .. 9).
Всё это работет только тогда, когда моя программа имеет фокус,
когда я делаю активной другую программу, то функция в любом случае
возвращает 0. Может мне кто-нибудь объяснить почему это происходит ?

function ControlKeyState :Integer;
 function KeyState(VirtualKeyCode :Byte) : Boolean;
 var
   State : TKeyboardState;
 begin
   GetKeyboardState(State);
   Result := ((State[VirtualKeyCode] And 128) <> 0);
 end;
begin
 Result := 0;
 if KeyState(VK_CONTROL) then result := 1;
 if KeyState(VK_MENU) then result := 2;
 if KeyState(VK_RWIN) or KeyState(VK_LWIN) then result := 3;
 if KeyState(VK_CONTROL) and KeyState(VK_MENU) then result := 4;
 if KeyState(VK_CONTROL) and ( KeyState(VK_RWIN) or KeyState(VK_LWIN)) then result := 5;
 if KeyState(VK_CONTROL) and KeyState(VK_SHIFT) then result := 6;
 if KeyState(VK_MENU) and (KeyState(VK_RWIN) or KeyState(VK_LWIN)) then result := 7;
 if KeyState(VK_CONTROL) and KeyState(VK_SHIFT) and KeyState(VK_MENU) then result := 8;
 if KeyState(VK_CONTROL) and KeyState(VK_MENU) and (KeyState(VK_RWIN) or KeyState(VK_LWIN)) then result := 9;
end;


 
VMcL ©   (2004-11-11 18:36) [1]

>>Сергей К. ©  (11.11.04 17:22)

GetAsyncKeyState
?


 
easy ©   (2004-11-11 19:26) [2]

result := (Word(GetKeyState(VirtualKeyCode)) and $8000) <> 0;


 
Сергей К. ©   (2004-11-12 10:07) [3]

всем спасибо заработало :)



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.034 c
1-1103032756
mega
2004-12-14 16:59
2004.12.26
раскрытие MenuItem


1-1102434424
DimonNew
2004-12-07 18:47
2004.12.26
Прорисовка StringGrid


9-1085643700
xman
2004-05-27 11:41
2004.12.26
Игра дурак


1-1102502874
mefisto
2004-12-08 13:47
2004.12.26
Вставка в ячейку DBGrid иконки 16х16 или Bitmap


1-1102751874
Dema-X
2004-12-11 10:57
2004.12.26
ошибка еакцессволюшион LoadFromStream




   Наверх