Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何使用Visual Basic禁用鼠标_Vb.net_Windows - Fatal编程技术网

Vb.net 如何使用Visual Basic禁用鼠标

Vb.net 如何使用Visual Basic禁用鼠标,vb.net,windows,Vb.net,Windows,我用autohotkey写了一个技术工具箱,但是很多AV软件已经开始破坏用autohotkey写的东西,所以我在VB.net中重做它 我已经能够完成大部分工作,但几乎所有使用我工具箱的人都使用的一个工具是禁用鼠标的热键。我们正在使用logmein远程工作,它只是阻止客户杀死病毒清除工具之类的东西 我已经找到了一种使用VB.net禁用鼠标和键盘的方法,但是它完全禁用了鼠标和键盘,而不仅仅是为了客户,我只想让它禁用鼠标,而不是键盘,因为当它杀死两个热键时,再次启用它们是不起作用的 下面是我一直在使用

我用autohotkey写了一个技术工具箱,但是很多AV软件已经开始破坏用autohotkey写的东西,所以我在VB.net中重做它 我已经能够完成大部分工作,但几乎所有使用我工具箱的人都使用的一个工具是禁用鼠标的热键。我们正在使用logmein远程工作,它只是阻止客户杀死病毒清除工具之类的东西

我已经找到了一种使用VB.net禁用鼠标和键盘的方法,但是它完全禁用了鼠标和键盘,而不仅仅是为了客户,我只想让它禁用鼠标,而不是键盘,因为当它杀死两个热键时,再次启用它们是不起作用的

下面是我一直在使用的代码

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Declare Function BlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer
Private Declare Function ShowCursor Lib "user32" (ByVal lShow As Long) As Long
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Timer1.Enabled = True
    Timer1.Interval = 1
    Dim mkey As Boolean
    Dim dkey As Boolean
    Dim ekey As Boolean
    mkey = GetAsyncKeyState(Keys.M)
    dkey = GetAsyncKeyState(Keys.D)
    ekey = GetAsyncKeyState(Keys.E)
    If mkey And dkey = True Then
        BlockInput(1)
        ShowCursor(0)
    End If

    If mkey And ekey = True Then
        BlockInput(0)
        ShowCursor(1)
    End If
End Sub
使能

BlockInput 1
禁用

BlockInput 0

不要在
Declare
指令(或p/invoke)中使用
Integer
Long
。相反,请使用
Int32
(或适当的其他尺寸)。您的许多声明都是错误的。@BenVoigt完全正确(+1)dwb它现在就是这样做的,它会阻止所有输入,所以您不能有一个热键来禁用,另一个热键来启用,另外,它不允许通过远程软件的操作覆盖它。有人能给我任何其他方法吗,因为这种方法不能满足我的需要,它会禁用键盘和鼠标。
BlockInput 0