Главная страница
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.023 c
1-1102751874
Dema-X
2004-12-11 10:57
2004.12.26
ошибка еакцессволюшион LoadFromStream


10-1067872500
dmuv
2003-11-03 18:15
2004.12.26
idl2pas и ее встроенность в Delphi


1-1102849985
speed
2004-12-12 14:13
2004.12.26
select ... listbox


1-1102940836
Wolffgang
2004-12-13 15:27
2004.12.26
опознание одинарной кавычки


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