2015-09-04 44 views
-1

我寫了一個在autohotkey技術工具箱,但很多AV軟件已經開始殺死寫在autohotkey的東西,所以我在VB重做它.net 我已經能夠獲得大部分的東西完成,但幾乎所有使用我的工具箱的人都使用的工具之一是禁用鼠標的熱鍵。我們正在遠程使用logmein,它只是阻止客戶殺死病毒清除工具等東西。如何禁用鼠標使用Visual Basic

我發現了一種方法來禁用鼠標和鍵盤使用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 
+1

不要在'Declare'指令使用'Integer'和'Long'(或P /調用)。相反,使用'Int32'(或適當的其他尺寸)。很多你的聲明是錯誤的。 –

+0

@BenVoigt這是完全正確的(+1) –

回答

1
Private Declare Function BlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer 

要啓用

BlockInput 1 

要禁用

BlockInput 0 
+0

dwb這就是它現在所做的,它阻止所有輸入,所以你不能有一個熱鍵來禁用和另一個啓用,也不允許通過遠程軟件的行動來覆蓋它。 –

+0

任何人都可以給我任何其他方式,因爲這種方式不會做我所需要的,它會禁用鍵盤以及鼠標。 –