簡體   English   中英

如何使用 Visual Basic 禁用鼠標

[英]How to disable mouse using Visual Basic

我用 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
Private Declare Function BlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer

啟用

BlockInput 1

禁用

BlockInput 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM