我是vb.net的新手。我尝试创建系统来禁用/锁定键盘。 此外,我尝试了谷歌的许多代码,但它只能以这种形式工作。我希望它永久禁用/锁定。
Public Class Form1
Private Declare Function BlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer
私有声明函数ShowCursor Lib“user32”(ByVal lShow As Long)As Long
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
BlockInput(1)
ShowCursor(0)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
BlockInput(0)
ShowCursor(1)
End Sub
End Class
感谢。
答案 0 :(得分:0)
尝试这个,但这会阻止鼠标和键盘,所以我会把一个计时器重新启用它
Public Class Form1
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = 5000 '5 seconds
Timer1.Enabled = True
BlockInput(True)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
BlockInput(False)
MsgBox("You can now use your mouse and keyboard")
End Sub
End Class