Intercept Alt + Tab, Alt + F4, Ctrl + ESC module in Win2k, I hope everyone likes! (Forgot to, from where the author, I apologize

zhaozj2021-02-16  48

'********************************************************** ************************ ** Module name: intercept Alt Tab, Alt F4, Ctrl ESC '**: 2004 May 16 ** Description: Use hook (), unload (), unloaded when loading, unload () "************************************************ ************************************************'in In Win2K, the hook () in the program is executed, you can intercept Alt Tab, Alt F4, Ctrl ESC

Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function SetWindowsHookEx Lib "user32" Alias ​​"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As LongPrivate Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As LongPrivate Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As IntegerPrivate Declare Sub CopyMemory Lib "kernel32 "Alias" RTLMoveMemory "(Destination as Any, Source As Any, Byval length As long)

Private Type Pkbdllhookstruct VKCode As Long Scancode As Long Flags As Long Time As Long Dwextrainfo As Longend Type

Private Const HC_ACTION = 0Private Const WM_KEYDOWN = & H100Private Const WM_SYSKEYDOWN = & H104Private Const WM_KEYUP = & H101Private Const WM_SYSKEYUP = & H105Private Const VK_TAB = & H9Private Const VK_ESCAPE = & H1BPrivate Const VK_CONTROL = & H11Private Const WH_KEYBOARD_LL = 13Private Const LLKHF_ALTDOWN = & H20

Private Prevhook As Long

Public Sub Hook () prevhook = setWindowshookex (wh_keyboard_ll, addressof lowlevelkeyboardproc, app.hinstance, 0) End Sub

Public Sub UnHook () UnhookWindowsHookEx PrevHookEnd SubPublic Function LowLevelKeyboardProc (ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim fEatKeystroke As Boolean Dim p As PKBDLLHOOKSTRUCT If ncode = HC_ACTION Then Select Case wParam Case WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP , WM_SYSKEYUP CopyMemory p, ByVal lParam, Len (p) If (p.flags And LLKHF_ALTDOWN) <> 0 Then 'Alt AnyKey fEatKeystroke = True End If If (p.vkCode = VK_ESCAPE) And ((GetKeyState (VK_CONTROL) And & H8000 ) <> 0) Then 'Ctrl Esc fEatKeystroke = True End If Case Else' do nothing End Select End If If fEatKeystroke Then LowLevelKeyboardProc = 1 Else CallNextHookEx WH_KEYBOARD_LL, ncode, wParam, lParam End IfEnd Function

转载请注明原文地址:https://www.9cbs.com/read-20013.html

New Post(0)