Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.12.26;
Скачать: 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 вся ветка

Текущий архив: 2004.12.26;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.069 c
1-1102933987
Bobby Digital
2004-12-13 13:33
2004.12.26
Float &amp; Int


1-1101998071
PAI
2004-12-02 17:34
2004.12.26
Демо-версия программы.


4-1099505032
CAMCOH
2004-11-03 21:03
2004.12.26
Как программно проскролить текст в memo ?


14-1102171935
sof_
2004-12-04 17:52
2004.12.26
IP адрес и доступ к дискам по сети


14-1102016407
av3nger
2004-12-02 22:40
2004.12.26
Статьи