there are sample codes to handle/disable keystrokes/keystrokes combination ctrl-alt-del, alt+tab but none for WINDOW key. anyone know how to disable WINDOW key?
there are sample codes to handle/disable keystrokes/keystrokes combination ctrl-alt-del, alt+tab but none for WINDOW key. anyone know how to disable WINDOW key?
pag create ug .bas with these codes
Option Explicit
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long,ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal cb As Long)
Private Const WH_KEYBOARD_LL = 13&
Private Const HC_ACTION = 0&
Public Const VK_LWINKEY = &H5B
Public Const VK_RWINKEY = &H5C
Private lKBDhook As Long
Private bHookEnabled As Boolean
Private Type KBDHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
Time As Long
dwExtraInfo As Long
End Type
Private o_KBDhook As KBDHOOKSTRUCT
Public Function KBDhookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode = HC_ACTION Then
Call CopyMemory(o_KBDhook, ByVal lParam, Len(o_KBDhook))
If (o_KBDhook.vkCode = VK_LWINKEY) And (o_KBDhook.flags = 1) Then
Debug.Print "You pressed the left Windows key. Normally the Start Menu would appear..."
KBDhookProc = 1
Exit Function
End If
If (o_KBDhook.vkCode = VK_RWINKEY) And (o_KBDhook.flags = 1) Then
Debug.Print "You pressed the right Windows key. Normally the Start Menu would appear..."
KBDhookProc = 1
Exit Function
End If
End If
KBDhookProc = CallNextHookEx(lKBDhook, nCode, wParam, lParam)
End Function
Public Function SetHook()
If lKBDhook = 0 Then
lKBDhook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KBDhookProc, App.hInstance, 0&)
End If
If lKBDhook = 0 Then
MsgBox "Failed to install Keyboard Hook"
bHookEnabled = False
Exit Function Else
bHookEnabled = True
End If
End Function
Public Function UnSetHook()
If bHookEnabled Then
Call UnhookWindowsHookEx(lKBDhook)
End If
bHookEnabled = False
End Function
unsaon pag gamit
(Form_Load or Sub Main): Call SetHook
(Form_Unload or cleanup sub): Call UnSetHook
it work.. but when i call UNSETHOOK and call SETHOOK the 2nd time it not longer handle window key stroke....Â*
btw, do made d code alone?
nope... got that code from somewhere.. nalimot ko.. gi embed lang nako ato gibuhat naku b4..Originally Posted by hybrid_X
ayt man tnx
Similar Threads |
|