![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Помогите с кодом
novenkiy © (2003-09-15 10:13:00)
Помогите добавить код так что бы хук срабатывал не на нажатия Q или W, a на нажатие Alt+Q и Alt+W
library lib;
uses
Windows, Messages;
var
H: THandle;
hw: hwnd;
function KeyboardProc(c0de, wm_char, lParam : integer): Lresult; stdcall;
begin
if (c0de =HC_ACTION) then
begin
case wm_char of
ord("Q"):
begin
keybd_event(VK_BACK,0,0,0);
keybd_event(vk_menu,0,0,0);
keybd_event( VK_NUMPAD0, MapVirtualKey(Vk_NumPad0,0), 0, 0 );
keybd_event( VK_NUMPAD0, MapVirtualKey(Vk_NumPad0,0), KEYEVENTF_KEYUP, 0 );
keybd_event( VK_NUMPAD1, MapVirtualKey(Vk_NumPad1,0), 0, 0 );
keybd_event( VK_NUMPAD1, MapVirtualKey(Vk_NumPad1,0), KEYEVENTF_KEYUP, 0 );
keybd_event( VK_NUMPAD5, MapVirtualKey(Vk_NumPad5,0), 0, 0 );
keybd_event( VK_NUMPAD5, MapVirtualKey(Vk_NumPad5,0), KEYEVENTF_KEYUP, 0 );
keybd_event( VK_NUMPAD6, MapVirtualKey(Vk_NumPad6,0), 0, 0 );
keybd_event( VK_NUMPAD6, MapVirtualKey(Vk_NumPad6,0), KEYEVENTF_KEYUP, 0 );
keybd_event(vk_menu,0,KEYEVENTF_KEYUP,0);
end;
ORD("W"):
begin
hw:=GetForegroundWindow;
SetWindowText(hw,"Хук работает");
end;
end;
end else
begin
result := CallNextHookEx(H, c0de, wm_char, lParam);
exit;
end;
result := CallNextHookEx(H, c0de, wm_char, lParam);
end;
procedure sethook;
begin
H:= SetWindowsHookEx(WH_keyboard, @KeyboardProc, hInstance, 0);
if H = 0 then
messageBox(0,"Не получилось...","ERROR",mb_iconhand);
end;
procedure removehook;
begin
UnhookWindowsHookEx(H);
end;
exports
sethook index 1 name "sethook",
removehook index 2 name "removehook",
end.
HolACost! (2003-09-25 16:27:00) [1]
Удалено модератором
Примечание: Флейм
novenkiy (2003-09-25 16:10:00) [2]
Удалено модератором
novenkiy (2003-09-25 16:09:00) [3]
Удалено модератором
novenkiy (2003-09-25 15:44:00) [4]
Удалено модератором
Примечание: В детский сад
AlexRush (2003-09-15 12:05:00) [5]
см. keystroke - lParam в KeyboardProc
Keystroke Message Flags:
бит 29 - Context Code.The context code indicates whether the ALT key was down when the keystroke message was generated. The code is 1 if the ALT key was down and 0 if it was up.
1 - ALT нажат, иначе нет.