![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Problema s GetKeyboardState [D6, NT4, Win2k, WinXP]
Сергей К. © (2004-11-11 17:22:00)Я внутри 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;
Сергей К. (2004-11-12 10:07:00) [1]всем спасибо заработало :)
easy (2004-11-11 19:26:00) [2]result := (Word(GetKeyState(VirtualKeyCode)) and $8000) <> 0;
VMcL (2004-11-11 18:36:00) [3]>> Сергей К. © (11.11.04 17:22)
GetAsyncKeyState
?