C# 中的 Java Robot 类等效代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11410015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Robot class eqivalent code in C#
提问by Naresh
Can somebody help me in converting the following java code to C#.
有人可以帮助我将以下 java 代码转换为 C#。
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyPress(KeyEvent.VK_M);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_M);
I understood we have to use 'user32.dll'. But I am not sure which methods we have to call.
我知道我们必须使用“user32.dll”。但我不确定我们必须调用哪些方法。
采纳答案by Osama Javed
If you are trying to simulate keyboard key presses, the following article should help you: http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library
如果您正在尝试模拟键盘按键,以下文章应该可以帮助您:http: //www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library
It has examples so it shouldn't be too hard to understand.
它有例子,所以它不应该太难理解。
回答by Felinis
The JAVA Robot class is designed for automated testing and operates at or below the HAL layer (Hardware Abstraction Layer). Simply generating keys and mouse movements programmatically is not the same thing as putting keys into the hardware keyboard buffer or the hardware mouse circuitry.
JAVA Robot 类专为自动化测试而设计,并在 HAL 层(硬件抽象层)或其以下运行。简单地以编程方式生成键和鼠标移动与将键放入硬件键盘缓冲区或硬件鼠标电路不同。