Please Help me !
I want to make SCREEN LOCK program(softwar) for my pc!
i want when SCREEN LOCK program start, then unable to close by user
but i am unable to do this.
when i press alt + f4, it's working great
but when i press alt + f1, oooh it's not working
here is my code

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyData = Keys.Alt + Keys.F1 Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyData = Keys.ControlKey + Keys.Alt + Keys.Delete Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyCode = Keys.Enter Then
            btnLogin_Click(sender, e)
        ElseIf e.KeyCode = Keys.Alt + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyCode = Keys.LWin + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyCode = Keys.RWin + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyCode = Keys.H + Keys.F1 Then
            MessageBox.Show("Your Software is Closing")
            e.Handled = False
        End If
    End Sub

Is there any particular reason your using e.KeyData on your first If statement line rather than e.KeyCode?

Did you try:

If e.KeyCode = Keys.Alt + Keys.F1 Then            
    MessageBox.Show("Nice Try, but did'nt work")            
    e.Handled = True

I try to use both "e.KeyCode" & "e.KeyData"
After Changeing the all key code are not working

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyData = Keys.Alt + Keys.F4 Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyData = Keys.ControlKey + Keys.Alt + Keys.Delete Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyCode = Keys.Enter Then
            btnLogin_Click(sender, e)
        ElseIf e.KeyData = Keys.Alt + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyData = Keys.LWin + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyData = Keys.RWin + Keys.Tab Then
            MessageBox.Show("Nice Try, but did'nt work")
            e.Handled = True
        ElseIf e.KeyData = Keys.F1 Then
            e.Handled = false
            Me.Close()
        End If
    End Sub
This article has been dead for over six months. Start a new discussion instead.