麻烦的鼠标/键盘问题 [英] Troublesome mouse/keyboard problem

查看:133
本文介绍了麻烦的鼠标/键盘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们

我正在制作一个程序,以将内容从管理员远程阻止到客户端PC
例如互联网访问等.

我想在单击按钮时阻止鼠标和键盘,然后在单击另一个按钮时启用.但是,Internet提供了奇怪的子类,钩子和注册表项.有没有人像样的代码?

注册表项仅在重新启动后起作用,因此无法选择.

我正在使用vb2010

顺便说一句,有人知道如何阻止和取消阻止Internet驱动程序吗?

非常感谢:)

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 :)

推荐答案


您可以尝试使用DirectX.运行使用DirectX唯一控制键盘和鼠标的服务或不可见程序(永远不会到达Load Event末尾的程序).我不知道Windows是否允许这样做,但是应该可以使用,特别是使用操纵杆等.

雅克
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


好吧,这是

首先,您必须下载Windows SDK(包括Direct X SDK),您还将希望下载可重新分发的Direct X,因为您的应用程序将需要它.

其次是Import语句:

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:

Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D



然后必须声明变量:



Then you must declare your variables:

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



要获取键盘和鼠标,请使用以下命令:



To Get the Keyboard and Mouse use this:

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();




注意:这仅使键盘和鼠标可以独占访问程序.
如果您编写额外的代码,您的程序仍然可以通过轮询获得键盘和鼠标输入.

Microsoft一遍又一遍地在其网站上说:出于安全原因,请勿将CooperativeLevelFlags设置为Exclusive(在键盘和鼠标上).您已经被警告了!

您的程序将必须摆脱限制.
我想到写一个专门使用键盘和鼠标的小应用程序.要启动限制,请启动应用程序.然后,要终止限制,您将必须通过Application.Close()方法找到某种方法来正确终止程序.我有一些想法,但我不会尝试解释.

我找不到未获取的代码段,因此我认为在应用程序退出时调用了未获取的代码.
借助于 http://www.developerfusion.com [




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.


这篇关于麻烦的鼠标/键盘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆