下面的程序不知道能否满足你的要求: 在FormLoad中加入以下代码: gHW = Me.hwnd Call RegisterHotKey(gHW, 0, 0, vbKeyF8) Hook 增加一个全局模块,其中有如下代码: Public Sub Hook() lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc) End SubPublic Sub Unhook() Dim temp As Long temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc) End SubFunction WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If uMsg = WM_HOTKEY Then If form1.cmdStart.Enabled = True Then form1.cmdStart_Click Exit Function End If End If WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam) End Function 自己注意一下参数声明吧。 这是我几年前的程序了,可以实现对F8键的系统级的热键。
我这里有
要我可以发给你
但请你把分给huangguanshu
还有个变态的方法。用DirectInput的keyboard类实现hook功能。要求别人的机器必须有DirectX7
在FormLoad中加入以下代码:
gHW = Me.hwnd
Call RegisterHotKey(gHW, 0, 0, vbKeyF8)
Hook
增加一个全局模块,其中有如下代码:
Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End SubPublic Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End SubFunction WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_HOTKEY Then
If form1.cmdStart.Enabled = True Then
form1.cmdStart_Click
Exit Function
End If
End If
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
自己注意一下参数声明吧。
这是我几年前的程序了,可以实现对F8键的系统级的热键。
用VC或Delphi做DLL吧,VB会把你搞晕的。我就晕过。