Вниз
Скачать: 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.024 c
14-1102316680
NeyroSpace
2004-12-06 10:04
2004.12.26
Утечка памяти в ZoneAlarm вер. 4.0.ххх и 5.0.ххх


4-1100073222
Lika
2004-11-10 10:53
2004.12.26
Com-порт


11-1084318593
Dilma
2004-05-12 03:36
2004.12.26
Как сделать табуляцию у элементов контейнеров?


1-1102666608
Игорь нтк
2004-12-10 11:16
2004.12.26
DBNavigator


1-1102777296
VasRog
2004-12-11 18:01
2004.12.26
Ссылки




   Наверх