Created
February 25, 2016 09:44
-
-
Save ShiningRay/afb8647649c8a27a601f to your computer and use it in GitHub Desktop.
Disable System Hotkey in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "windows.bi" | |
Dim shared as HANDLE hook | |
function LowLevelKeyboardProc(byval nCode as long, byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT | |
if nCode < 0 then | |
return CallNextHookEx(NULL, nCode, wParam, lParam) | |
end if | |
var s = cptr(LPKBDLLHOOKSTRUCT, lParam) | |
select case s->flags | |
case LLKHF_ALTDOWN | |
print "ALT" | |
Deallocate s | |
return 1 | |
end select | |
if wParam = WM_KEYDOWN then | |
select case s->vkCode | |
case VK_RWIN, VK_LWIN, VK_LCONTROL, VK_RCONTROL, VK_APPS, VK_SLEEP, VK_MENU | |
print "SPECIAL PRESS" | |
Deallocate s | |
return 1 | |
end select | |
end if | |
return CallNextHookEx(NULL, nCode, wParam, lParam) | |
end Function | |
hook = SetWindowsHookEx(WH_KEYBOARD_LL,ProcPtr(LowLevelKeyboardProc),GetModuleHandle(NULL),0) | |
if hook <> NULL then | |
print "hook true" | |
else | |
print "hook false" | |
end if | |
Dim as MSG wMsg | |
While( GetMessage( @wMsg, Null, 0, 0 ) <> False ) | |
TranslateMessage( @wMsg ) | |
DispatchMessage( @wMsg ) | |
Wend | |
if UnhookWindowsHookEx(hook) then | |
print "unhook true" | |
else | |
print "unhook false" | |
end if | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment