|
-
Mar 28th, 2008, 10:36 AM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] Disable mouse and keyboard input?
Is there a way I can do this easily? I have a main form loading with 3 check boxes that the user can choose, mouse input , keyboard input or both. Instead of loading 3 seperate forms is there a way I can just disable input from mouse if they choose keyboard only or disable keyboard if they choose mouse.. or do I have to make each form seperate? Thanks for advice.
-
Mar 28th, 2008, 11:20 AM
#2
Frenzied Member
Re: [2005] Disable mouse and keyboard input?
Here try using booleans the code i will show will just give an example of how to do it so you cna figure the rest urself.
vb Code:
Public Class Form1
Dim keyboard_used As Boolean = False
Dim mouse_used As Boolean = False
Private Sub Button1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyUp
If e.KeyCode = Keys.Enter Then
keyboard_used = True
mouse_used = False
End If
End Sub
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
keyboard_used = False
mouse_used = True
End If
End Sub
End Class
-
Mar 28th, 2008, 11:21 AM
#3
Frenzied Member
Re: [2005] Disable mouse and keyboard input?
Thats an example with buttons now change the buttons to checkboxes and make the actions code only work when one of the booleans = true or something like that.
-
Mar 28th, 2008, 11:24 AM
#4
Re: [2005] Disable mouse and keyboard input?
I'm confused. Why would you want to disable one or the other? If you can have both then why can't people just use the one(s) they want?
-
Mar 28th, 2008, 11:27 AM
#5
Frenzied Member
Re: [2005] Disable mouse and keyboard input?
Oh ya PlanetX what is the point is there a specfic reason because then maybe there is another set of code that can be used or another solution.
-
Mar 28th, 2008, 02:58 PM
#6
Thread Starter
Lively Member
Re: [2005] Disable mouse and keyboard input?
sorry this is a mastermind game assignment and i need to have a menu at the start for letting the user choose keyboard or mouse input, or both. I haven't had a chance to look at the code yet to see if I can get it working but I will as soon as I'm off work. Thanks for the advice , appreciate it. Maybe there is an easier way and I am not aware of.
-
Mar 28th, 2008, 09:13 PM
#7
Hyperactive Member
Re: [2005] Disable mouse and keyboard input?
This could be a start:
Add 3 checkboxes: Disablemouse, Disablekeyboard and Disableboth
Code:
Public Class Form1
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
Private Sub Disableboth_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Disableboth.CheckedChanged
If Disableboth.Checked = True Then
BlockInput(True)
Threading.Thread.Sleep(1000) 'blocks for 1 second
BlockInput(False)
End If
End Sub
End Class
As you can see i only know a way to block both keyboard AND mouse until Crt + Alt + Del is pressed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|