|
|
我做了个软件,点一个按钮可以关闭显示器信号,但移动鼠标或敲击键盘都会默认打开显示器,我想屏蔽鼠
标,使用了SetWindowsHookEx将鼠标移动信息转为我的函数处理代码为
Function HookProc(ByVal code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim i As Long, j As Integer
If code <> HC_ACTION Then
HookProc = CallNextHookEx(hHook, code, wParam, lParam)
Exit Function
End If
CopyMemory msg, lParam, LenB(msg)
If n = False And msg.message = WM_KEYUP Then
SendMessage GetForegroundWindow, WM_SYSCOMMAND, SC_MONITORPOWER, -1
n = True'n 显示器状态
Exit Function
End If
If n = False And msg.message = WM_KEYDOWN Then
SendMessage GetForegroundWindow, WM_SYSCOMMAND, SC_MONITORPOWER, -1
n = True
Exit Function
End If
If n = False And msg.message = WM_MOUSEMOVE Then
HookProc = 1
SendMessage GetForegroundWindow, WM_SYSCOMMAND, SC_MONITORPOWER, 2'关闭显示器
n = False
Exit Function
End If
End Function
但编译执行后并没有完全屏蔽,有时移动鼠标会显示器无显示,有时又有显示.不符合我的要求.望高手指教 |
|