vb锁定 键盘 鼠标
运行程序后就锁定键盘及鼠标有代码的就发啊zhiailxm@vip.qq.com运行该程序后就让键盘无法运行热键还有锁定他的鼠标让他点击不得...
运行程序后就锁定键盘及鼠标 有代码的就发啊zhiailxm@vip.qq.com
运行该程序后就让键盘无法运行热键还有锁定他的鼠标让他点击不得 展开
运行该程序后就让键盘无法运行热键还有锁定他的鼠标让他点击不得 展开
7个回答
展开全部
简单!
用 API 函数,EnableWindow()。
详细说明:
让窗口让睁拒绝接受键盘和鼠标事件
声明:
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
使用:
'拒绝接受键厅森盘和鼠标事件
Call EnableWindow(Form.hwnd, 0)
'允许接扮滑亩受键盘和鼠标事件
Call EnableWindow(Form.hwnd, 1)
用 API 函数,EnableWindow()。
详细说明:
让窗口让睁拒绝接受键盘和鼠标事件
声明:
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
使用:
'拒绝接受键厅森盘和鼠标事件
Call EnableWindow(Form.hwnd, 0)
'允许接扮滑亩受键盘和鼠标事件
Call EnableWindow(Form.hwnd, 1)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建一个模块Module1,其代码如下。
=========
Declare Sub Sleep Lib "KERNEL32" (ByVal dwMilliseconds As Long)
Public Const WH_JOURNALPLAYBACK = 1
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
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
Sub EnableHook()
hNxtHook = SetWindowsHookEx(WH_JOURNALPLAYBACK, AddressOf HookProc, App.hInstance, 0)
End Sub
Sub FreeHook()
UnhookWindowsHookEx hNxtHook
End Sub
Function HookProc(ByVal code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
HookProc = CallNextHookEx(hNxtHook, code, wParam, lParam)
End Function
=====
Form1里面的代码很简单。
Private Sub Form_Load()
EnableHook
Sleep 10000 '这一句的作用是让键盘鼠标失效10秒,如果你想让他一直失效衫胡拿,去掉或搭这一句和做梁下面一句
FreeHook
End Sub
=========
Declare Sub Sleep Lib "KERNEL32" (ByVal dwMilliseconds As Long)
Public Const WH_JOURNALPLAYBACK = 1
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
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
Sub EnableHook()
hNxtHook = SetWindowsHookEx(WH_JOURNALPLAYBACK, AddressOf HookProc, App.hInstance, 0)
End Sub
Sub FreeHook()
UnhookWindowsHookEx hNxtHook
End Sub
Function HookProc(ByVal code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
HookProc = CallNextHookEx(hNxtHook, code, wParam, lParam)
End Function
=====
Form1里面的代码很简单。
Private Sub Form_Load()
EnableHook
Sleep 10000 '这一句的作用是让键盘鼠标失效10秒,如果你想让他一直失效衫胡拿,去掉或搭这一句和做梁下面一句
FreeHook
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function BlockInput Lib "user32"颤者昌 (ByVal fEnable As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
BlockInput (5) '失去控制
Call Sleep(20000)
'20秒茄扒后恢复 ,如果不想恢复 删除 Call Sleep(20000) 和 BlockInput (0)
BlockInput (0) '嫌桐恢复
End Sub
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
BlockInput (5) '失去控制
Call Sleep(20000)
'20秒茄扒后恢复 ,如果不想恢复 删除 Call Sleep(20000) 和 BlockInput (0)
BlockInput (0) '嫌桐恢复
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function SetParent Lib "燃孙并袭user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private WithEvents Timer1 As Timer
Private Sub Form_Load()
Set Timer1 = Me.Controls.Add("VB.Timer"皮蔽链, "Timer1")
Timer1.Enabled = True
Timer1.Interval = 10
Me.Hide
End Sub
Private Sub Timer1_Timer()
SetParent GetForegroundWindow, Me.hWnd
End Sub
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private WithEvents Timer1 As Timer
Private Sub Form_Load()
Set Timer1 = Me.Controls.Add("VB.Timer"皮蔽链, "Timer1")
Timer1.Enabled = True
Timer1.Interval = 10
Me.Hide
End Sub
Private Sub Timer1_Timer()
SetParent GetForegroundWindow, Me.hWnd
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询