| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2010 人关注过本帖
标题:vb屏蔽键盘操作的模块中如何排除空格键
取消只看楼主 加入收藏
a516526966
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-26
收藏
 问题点数:0 回复次数:1 
vb屏蔽键盘操作的模块中如何排除空格键
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
'idHook参数代表拦截的类型,主要有键盘、鼠标等(当拦截键盘输入时值为2)
'lpfn参数代表Hook函数的位址
'hmod代表.dll的hInstance
'dwThreadId代表执行拦截的ThreadId
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WH_KEYBOARD = 2
Public Const WH_KEYBOARD_LL = 13
Public Const WH_SHELL = 10
Public Const WH_GETMESSAGE = 3
Public Const WH_CALLWNDPROC = 4
Public h_Hook As Long
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP As Long = &H205
Public hHook As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Type tagKBDLLHOOKSTRUCT
    vkCode       As Integer          '// virtual key code
    scanCode     As Integer        '// scan code
    flags        As Long   '// flags
    Time         As Long    '// time stamp for this message
    dwExtraInfo  As Long '// extra info from the driver or keybd_event
End Type
Public Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long

Sub EnableHook() '定义EnableHook
'设置拦截
    hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf Myfunc, App.hInstance, 0)
End Sub

Sub DisableHook() '定义DisableHook
    Dim ret As Long
    ret = UnhookWindowsHookEx(hHook) '取消拦截
End Sub

Function Myfunc(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'wParam代表按键
    'On Error Resume Next
Dim kk As tagKBDLLHOOKSTRUCT
Dim kb As Long, pks As Byte
    'Debug.Print wParam
    CopyMemory kk, lParam, Len(kk)
    'If wParam = 256 Then
    Myfunc = 1: Exit Function
    'endif
    Myfunc = CallNextHookEx(hHook, ncode, wParam, lParam) '传到下一个拦截
End Function

Public Function MyKBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If ncode = 0 Then
MyKBHook = 1
End If
End Function

Public Function My_KBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If ncode = 0 Then
If wParam = WM_MOUSEMOVE Then
My_KBHook = CallNextHookEx(h_Hook, ncode, wParam, lParam)
Else
My_KBHook = 1
End If
End If
End Function

请教一下,此模块中如何排除屏蔽空格按键?
搜索更多相关主题的帖子: Function ByVal Long Public Const 
2018-08-19 15:55
a516526966
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-26
收藏
得分:0 
有大神能解决一下吗?
2018-08-22 12:59
快速回复:vb屏蔽键盘操作的模块中如何排除空格键
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051605 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved