Hey everyone, im currently use this class for my small projects:
https://www.daniweb.com/software-development/vbnet/threads/361868/disable-ctrl-alt-del

Now i have problem, i want to hide my form and close jammer so i use something like this:

Private Sub SystemTray()
        If NotifyIcon1.Visible = True Then
            KeyboardJammer.Jam()
            NotifyIcon1.Visible = False
            taskbar.HideStartButton()
            taskbar.HideTaskBar()
            Me.Show()
        ElseIf NotifyIcon1.Visible = False Then
            KeyboardJammer.UnJam()
            NotifyIcon1.Visible = True
            taskbar.ShowStartButton()
            taskbar.ShowTaskBar()
            Me.Hide()
        End If 
End Sub

Now problem is when i hide my form actually ALT F4 and other keys works.. As it should work. But when i restore my form it works again like 'KeyboardJammer.Jam()' doesnt start at all? o.O And it doesnt show any error...

What is most likely happening is that you are exiting the main thread when you use Alt+F4; thus no code will fire the code to 'jam' the keyboard.

Nah u dont understand... when i first time start application Keyboard Jammer works. When i hide form1 i use Unjam so i can use alt tab and such.. when i show again form1 back from tray Jammer wont start working i can again use alt tab and such...

I'm not sure if I get your problem correct here. I think you are trying to say you are able to jam the keyboard on startup or before you hide the form but after you re-show the form it suppose to jam again the keyboard but it doesn't. Am I right? If so the reason for it not jamming again is that your jamming code or jamming function is on startup or the main call to the jam function is on Form load which is a reason why it do jam on startup so what you need to know is that the form doesn't start twice while the program is on debug especially the main form or the starting form so when you hide the form you are not terminating it but you are hiding it so when you show it again it won't read the startup or form load codes because it was already running it just that it wasn't shown on screen so you need to create another function or put your codes on under the call to show the form don't remove the code or call on form load they must be 2.

The one on form load and also
The one bellow the call you used to show the form back on screen.

Ok try posting your code here so we can have a look at why it doesn't work. Please ensure you comment on codes for easy referral.

Well i posted it already on top? o.O I use whole code from that link.. Even this one:

Private Sub Form1_HandleCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.HandleCreated
        KeyboardJammer.Jam()
End Sub
Private Sub Form1_HandleDestroyed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.HandleDestroyed
        KeyboardJammer.UnJam()
End Sub

And this snippet is for my show/hide form:

Private Sub SystemTray()
        If NotifyIcon1.Visible = True Then
            KeyboardJammer.Jam()
            NotifyIcon1.Visible = False
            taskbar.HideStartButton()
            taskbar.HideTaskBar()
            Me.Show()
        ElseIf NotifyIcon1.Visible = False Then
            KeyboardJammer.UnJam()
            NotifyIcon1.Visible = True
            taskbar.ShowStartButton()
            taskbar.ShowTaskBar()
            Me.Hide()
        End If 
End Sub

Ok the problem seem to be on your last snippet. You are blocking the events because you interlinked it. I quote "

 If NotificationIcon.Visible = True Then
 KeyBoardJammer.Jam()

This is correct but you need to set something that will (let say when you are pressing and hold Shift for maybe 5 seconds then NotificationIcon1.Visible = True() 'Here is what will detect when to jam and when not to.) So what I'm saying is that you need something that will do something like this but what you did wrong is also calling

 If NotificationIcon1.Visible = False() Then

So the problem is that you said if the icon is visible jam the keyboard and you also set the icon visibility to false and you also have codes that disable jamming so you need to separate this with a more different event handler then the on you used.

Change the event handler don't use if icon is visible or false because you also set the visibility after calling a function which also result in the system to unjam

Well i made it run SystemTray() on login button click now:
If NotifyIcon1.Visible = True Then
When user click login and if notifyicon is visible i want to hide it .. If its not visible: ElseIf NotifyIcon1.Visible = False Then i want to make it visible :)

Well the code doesn't say what you are saying, in code you are checking if the icon is visible or not and what you are doing is that if the icon is visible you are jamming and also just after it has jammed you are also hiding the icon and below that is an IF statement automatically checking on it own if the icon is not visible so in this stage because you have hidden the icon now it will just to read this because the visibility state has now change to false so it will fire the code of which is unjamming the keyboard.

Try using event handlers, I will try tomorrow to post a sample code on how you should do it because for now I'm running out of Battery and I'm not near charger

I've changed it to use keyjam on form1 load and unjam on form1 close and it works i start then settings form, but when i click button to run again form1 as new form it still let me using hotkeys which is strange? :S

This article has been dead for over six months. Start a new discussion instead.