Click here to Skip to main content
15,881,739 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi people

i'm making a program to remotely block stuff from an administrator to a client PC
such as internet access, etc.

i want to block the mouse and keyboard on a button click, then enable when i click another button. however, the internet provides strange subclassing, hooks and registry keys. does anyone have a decent code?

The registry keys only work upon reboot-therefore not an option.

i'm using vb2010

by the way, does anyone know how to block AND UNBLOCK internet drivers?

thanks very much :)
Posted
Comments
Sergey Alexandrovich Kryukov 31-Oct-12 14:13pm    
What do you mean by VB, exactly? VB.NET, I presume? Then tag it VB.NET, which is not quite a VB. You are the one who is most interested in appropriate tags.
What "block a driver" is supposed to mean, exactly? The purpose? :-)
--SA

Hi
You can try using DirectX. Run a Service or invisible program(one that never reaches the end of the Load Event) that uses DirectX to take sole control over the keyboard & mouse. I don't know if Windows will allow this, but it is supposed to work, especially with joysticks etc.

Jacques
 
Share this answer
 
Comments
[no name] 4-Nov-12 14:21pm    
Ok. Thanks for replying.
How would i go around controlling DirectX to control the mouse/keyboard?
i thought you could just have something like this in VB:
<DllImport #whatever#>

then:

button1.click:

blockMouseAndKeyboard(True)

then none of the system can be controlled
do you have anything like this?
Jacques Loubser 6-Nov-12 3:30am    
Let me try and work out the code, then I will post it. I don't have it in VB, but I found a conversion tool.
[no name] 6-Nov-12 10:49am    
brilliant! thanks so much for taking your time and not ignoring me like other web users :)
Nelek 11-Nov-12 10:40am    
OP's comment moved from non-solution below
so... do you have the code yet? i'm sorry if it seems like i'm rushing you, but my project hangs on your answer. thanks :)
Jacques Loubser 12-Nov-12 7:33am    
Done! Check out the solutions, it is among them.
Okay Here it Is

First, you must download ht Windows SDK (it has the Direct X SDK included) You will also want to download a redirstrabutable Direct X as you will your application will require it.

Second here are the Import statements:

VB
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D


Then you must declare your variables:

VB
Dim keyboard As DirectInput.Device = Nothing
Dim mouse As DirectInput.Device = Nothing


To Get the Keyboard and Mouse use this:

C#
keyboard.SetCooperativeLevel(
this,
DirectInput.CooperativeLevelFlags.Background | DirectInput.CooperativeLevelFlags.Exclusive );
keyboard = new DirectInput.Device( DirectInput.SystemGuid.Keyboard );
keyboard.Acquire();

mouse = new DirectInput.Device( DirectInput.SystemGuid.Mouse );
mouse.SetCooperativeLevel(
this,
DirectInput.CooperativeLevelFlags.Background | DirectInput.CooperativeLevelFlags.Exclusive );
mouse.SetDataFormat( DirectInput.DeviceDataFormat.Mouse );
mouse.Acquire();



Note: This only gives exclusive access of the Keyboard and Mouse to your Program.
Your program can still get keyboard and mouse inputs (by polling) if you write the extra code.

Microsoft say over and over again on their website, "For security reasons, do not set the CooperativeLevelFlags to Exclusive"(on the keyboard and mouse). You have been warned!!!

Your program will have to handle getting rid of the restriction.
I thought of writing a small app that takes the keyboard and mouse exclusively. To start the restriction, start the app. Then to terminate the restriction, you will have to find some way to terminate the program properly, through the Application.Close() method. I have some Ideas, but I am not going to try to explain it.

I can't find a unacquire snippet, so I think unacquire is called on App Exit.
This code has been converted to VB from C# with the help of http://www.developerfusion.com[^]
If it does not work, I can write the small app in C# for you.
 
Share this answer
 
Comments
[no name] 19-Nov-12 11:43am    
Thanks very much, guys! i just installed the DirectX stuff and the download is going to take 1 hour 1 minute so i will test the code later- but thanks for helping!
Jacques Loubser 19-Nov-12 11:57am    
I know, that thing is huge!
[no name] 19-Nov-12 12:09pm    
AHHHHHHHHHH!
i'm SO FRUSTRATED right now
i don't want to download anything, i just want a simple code. why can't anyone just give me a SIMPLE CODE that doesn't need any stupid external programs?
Jacques Loubser 20-Nov-12 1:34am    
Then you are back to strange subclassing, hooks and registry keys. Direct X is for the serious game developer. It can draw, play sound, accept input from the joystick and even play force feedback effects. To package something so specific into a language would give it excess weight just so 1 in 100 people can use it. By using an external 'Kit' streamlines the language but still lets 1 in 100 people have it as and when they want it. You are not going to get more 'SIMPLE CODE' than this.
[no name] 20-Nov-12 11:01am    
i really don't want you to think i disregard your efforts to help, but if i download the SDK, won't this be required on every other computer that it's run on? i was just hoping for a code that every computer can use, like a DLL. i tried blockinput, but this only does it for the form, and not system-wide.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900