唉!我亲爱的键盘啊!
我亲爱的键盘啊!这么多年风风雨雨都过来了,为什么偏偏在这个时候不好用了呢?你哪个回车键,为什么一按下去就不弹起来了呢?我曾经试着用拳头砸过你,没有用;我又用锤头砸过你,结果回车键更弹不起来了!有心将你弃之东隅,但转念一想,我抚摸了这么长时间、对我这么有感情的东西,怎么能将它放弃呢?硬的不行,只好,来点软的吧!于是乎,我七拼八凑,写了点代码,将你搞定。
模块中:
Private hHook As Long
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
Declare Function CallNextHookEx Lib "user32 " _
(ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll " Alias "RtlMoveMemory " (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
'很多没用的,也加上了
Private Const WH_CALLWNDPROC = 4
Private Const WH_CALLWNDPROCRET = 12
Private Const WH_CBT = 5
Private Const WH_DEBUG = 9
Private Const WH_FOREGROUNDIDLE = 11
Private Const WH_GETMESSAGE = 3
Private Const WH_HARDWARE = 8
Private Const WH_JOURNALPLAYBACK = 1
Private Const WH_JOURNALRECORD = 0
Private Const WH_KEYBOARD = 2
Private Const WH_MOUSE = 7
Private Const WH_MSGFILTER = (-1)
Private Const WH_SHELL = 10
Private Const WH_SYSMSGFILTER = 6
Private Const WH_KEYBOARD_LL = 13
Private Const WH_MOUSE_LL = 14
Private Const HC_ACTION As Integer = 0
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_SYSKEYDOWN As Integer = &H104
Private Const WM_SYSKEYUP As Integer = &H105
Private Type EVENTMSG
wMsg As Long
lParamL As Long
lParamH As Long
msgTime As Long
hWndMsg As Long
End Type
Private EMSG As EVENTMSG
Dim lastTimer As Double
Public Sub UnHookKBD()
If hHook <> 0 Then
UnhookWindowsHookEx hHook
hHook = 0
End If
End Sub
Public Function EnableKBDHook()
If hHook <> 0 Then
Exit Function
End If
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf _
MyKBHFunc, App.hInstance, ByVal 0&)
End Function
Private Function MyKBHFunc(ByVal iCode As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If iCode <> HC_ACTION Then Exit Function
If wParam = WM_KEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Or wParam = WM_SYSKEYDOWN Then
CopyMemory EMSG, ByVal lParam, Len(EMSG)
If EMSG.wMsg = 13 Then '侦测 有没有按到Enter键
If Abs(lastTimer - Timer) <= 0.05 Then MyKBHFunc = 1 '在这个Hook便吃掉这个讯息
lastTimer = Timer
Exit Function
End If
End If
Call CallNextHookEx(hHook, iCode, wParam, lParam) '传给下一个Hook
End Function
窗口中:
Private Sub Form_Load()
EnableKBDHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHookKBD
End Sub
只要我在使用键盘前,打开这个小程序,就不会出现因长时间连续按回车键而无数次打开同一个程序而死机了!
[解决办法]
我亲爱的楼主啊!这么多年风风雨雨都过来了,为什么偏偏在这个时候才把键盘搞坏呢?你那个破键盘,为什么现在才坏的无可救药呢?我曾经试着用心灵感化,没有用;我又用咒语诅咒过,结果破键盘还是能用!有心让你将你弃之东隅,但转念一想,你抚摸了这么长时间、肯定有感情了的东西,你应该不会放弃。硬的不行,只好,来点软的吧!于是乎,软磨硬泡,你那破键盘终于无法回车,于是你就有了给我分的理由。
[解决办法]
代码学习中
这是炫耀代码还是痛惜键盘?
[解决办法]
貌似有个键盘精灵可以重新设置按键位置
[解决办法]
楼主节哀,还是把键盘统统拆开,给每个键洗个澡吧.
不经意,你会发现许多本来必定要被埋没于尘埃中的回忆.
一颗芝麻,让你想起了5年前女朋友为你买的那顿早饭,
一个断开的笔尖,让你想起了4年前女友和你分手后的郁闷,
一片纸屑上残留着的半个电话号码,让你想起了3年前第一次叫"外卖"时的冲动.
一块融化了一半的硬糖,让你想起了2年前死在键盘上的那只大胆的小强.
一片已经发黑的奶渍,让你想起了去年边喝牛奶边看A片时你老爸忽然进房间时你的紧张.
一截已经断裂的弹簧,让你明白了最终导致陪伴了你N年的键盘为何要罢工.
...
[解决办法]
学习了
使劲顶............
呼!
楼上几位该减肥了
[解决办法]
顺便问一句:
大家都有多少吨位...?
[解决办法]
恐怖。。。。高手
[解决办法]
原来可以这样修键盘........
[解决办法]
学习***
好多星星啊………………
[解决办法]
学习了~~~~星爷就是不一样!!!
[解决办法]
好快的回车,犹如白驹过隙,一刹那间许多空行落下
我只在乎,那一回车的风情
[解决办法]
CCCCCCCCCCCCCCCC
[解决办法]
开头 结束 我都包了