Voici mon problème :
J'ai trouver ce hook sur internet (enfin ... presque, j'ai seulement modifier les debug.writeline() pour msgbox()) et je voulais savoir si quelqu'un peut me dire pourquoi lorsque je l'exécute, j'obtien un msgbox disant :
Keyboard hook failed: 0 le zéro corespond a un code d'erreur provenant de la dll user32.
Je ne connais pas très bien les hooks, c'est mo premier, alors ne soyez pas trop méchant
Suite du code au prochain message ^^
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 PublicDeclareFunction UnhookWindowsHookEx Lib"user32" (ByVal hHook AsInteger) AsInteger PublicDeclareFunction SetWindowsHookEx Lib"user32"Alias"SetWindowsHookExA" (ByVal idHook AsInteger, ByVal lpfn As KeyboardHookDelegate, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger PrivateDeclareFunction GetAsyncKeyState Lib"user32" (ByVal vKey AsInteger) AsInteger PrivateDeclareFunction CallNextHookEx Lib"user32" (ByVal hHook AsInteger, ByVal nCode AsInteger, ByVal wParam AsInteger, ByVal lParam As KBDLLHOOKSTRUCT) AsInteger PublicStructure KBDLLHOOKSTRUCT Public vkCode AsInteger Public scanCode AsInteger Public flags AsInteger Public time AsInteger Public dwExtraInfo AsInteger EndStructure ' Low-Level Keyboard Constants PrivateConst HC_ACTION AsInteger = 0 PrivateConst LLKHF_EXTENDED AsInteger = &H1 PrivateConst LLKHF_INJECTED AsInteger = &H10 PrivateConst LLKHF_ALTDOWN AsInteger = &H20 PrivateConst LLKHF_UP AsInteger = &H80 ' Virtual Keys PublicConst VK_TAB = &H9 PublicConst VK_CONTROL = &H11 PublicConst VK_ESCAPE = &H1B PublicConst VK_DELETE = &H2E PublicConst VK_LWIN = &H5B PublicConst VK_RWIN = &H5C PrivateConst WH_KEYBOARD_LL AsInteger = 13& Public KeyboardHandle AsInteger ' Implement this function to block as many ' key combinations as you'd like PublicFunction IsHooked(ByRef Hookstruct As KBDLLHOOKSTRUCT) AsBoolean Debug.WriteLine("Hookstruct.vkCode: " & Hookstruct.vkCode) Debug.WriteLine(Hookstruct.vkCode = VK_ESCAPE) Debug.WriteLine(Hookstruct.vkCode = VK_TAB) If (Hookstruct.vkCode = VK_ESCAPE) AndCBool(GetAsyncKeyState(VK_CONTROL) And&H8000) Then Call HookedState("Ctrl + Esc blocked") ReturnTrue EndIf If (Hookstruct.vkCode = VK_TAB) AndCBool(Hookstruct.flags And LLKHF_ALTDOWN) Then Call HookedState("Alt + Tab blockd") ReturnTrue EndIf If (Hookstruct.vkCode = VK_ESCAPE) AndCBool(Hookstruct.flags And LLKHF_ALTDOWN) Then Call HookedState("Alt + Escape blocked") ReturnTrue EndIf ReturnFalse EndFunction
Partager