Java ps / 2命令? [英] Java ps/2 commands ?

查看:58
本文介绍了Java ps / 2命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..



我目前正在使用ps / 2鼠标和键盘。起初我认为ps / 2端口只能用于从鼠标和键盘等设备读取一些输入。但是在Windows中,当计算机为用户做好准备时,它会自动打开或关闭一些锁定。



我的意思是如果用户确实关闭了带有numlock的capslock打开并关闭计算机,下次启动计算机时,Windows会自动恢复用户之前配置的设置。在这种情况下关闭带有打开numlock的封锁。



这就是我想知道的。软件是否可以与ps / 2设备通信?我的意思是将一些数据发送到ps / 2设备?这是Windows如何恢复锁定键设置? Windows是否向键盘发送命令以打开numlock?或其他什么?



此外,如果可以通过ps / 2端口向键盘发送一些命令,我​​是否可以创建一个可以发送命令的程序对老鼠? :)



提前致谢!

Hi..

Im currently using a ps/2 mouse and a keyboard. At first I thought ps/2 ports can only be used to read some input from devices such as mice and keyboards. But in windows, when the computer becoming prepared to the user it automatically on or off some locks as it as been before.

I mean if the user did turn off the capslock with numlock turned on and shut down the computer, next time he start the computer windows would automatically restore the settings user had been configured before. In this case turned off capslock with turned on numlock.

And that's what I wonder about. Does a software can be communicated with ps/2 devices ? I mean send some data to ps/2 devices ? Is that how windows restore the lock key settings back ? Does the windows send a command to the keyboard to turn on the numlock ? or something else ?

Furthermore, If it's possible to send some commands to the keyboard via ps/2 port, will I be able to create a program that can send commands to the mouse ? :)

Thanks in advance !

推荐答案

我不确定操作系统是如何实现的打开/关闭这些灯。但是使用Java你可以告诉操作系统这样做。我希望这有帮助?



I'm not sure how the OS is able to turn these light on/off. But using Java you can tell the OS to do it. I hope this helps?

import java.awt.Toolkit;
import java.awt.event.KeyEvent;

public class Driver
{
	public static void main(String[] args)
	{
		// turn num lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, true);
		// turn num lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, false);
		// get num lock state
		boolean isNumLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
		
		// turn caps lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, true);
		// turn caps lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);
		// get caps lock state
		boolean isCapsLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
		
		// turn caps lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, true);
		// turn caps lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false);
		// get scroll lock state
		boolean isScrollLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
	}
}


这篇关于Java ps / 2命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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