Public Class Form1

  Private WithEvents KeyMonitor As dwl

  Public Sub New()
    InitializeComponent()
    Me.KeyMonitor = New dwl
  End Sub

  Private Sub dwlKeydown(ByVal sender As System.Object, ByVal e As dwlKeyEventArgs) Handles KeyMonitor.KeyDown
    Dim S As String
    dwl.wlVkToStr("", e.KeyCode, dwl.KeysToMF(e.Modifiers), S)
    lKey.Text = S
  End Sub


  Private Sub UpdateDisables(ByVal Keys As String())
    Dim vk As Integer
    Dim mf As Integer
    dwl.wlDisableKey(0, 0, 0, 0)                'enable all keys

    For index As Integer = 0 To Keys.Length - 1

      If Keys(index) <> "" Then
        dwl.wlStrToVk(Keys(index), "", 0, vk, mf)
        If vk = 0 Then
          MessageBox.Show("can not disable key")
        Else
          dwl.wlDisableKey(0, vk, mf, 1)
        End If
      End If
    Next
  End Sub

  Private Sub bDisable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bDisable.Click
    If lKey.Text <> "None" Then
      TextBox1.AppendText(lKey.Text + Environment.NewLine)
      UpdateDisables(TextBox1.Lines)
    End If
  End Sub

  
Private Sub bUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bUpdate.Click
  UpdateDisables(TextBox1.Lines)
End Sub

Private Sub bClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bClear.Click
    TextBox1.Text = ""
    UpdateDisables(TextBox1.Lines)
End Sub
End Class
