简体   繁体   English

如何调用低级KeyHook组合键?

[英]How to call Low-Level KeyHook Key-Combinations?

I really can't solve this problem and don't even know, if it is possible. 我真的无法解决这个问题,甚至不知道,如果可能的话。

I want to use CTRL+C and CTRL+V shortcuts. 我想使用CTRL + CCTRL + V快捷键。

Example: There is 2 Application. 示例:有2个应用程序。 1. App is written in C#, 2. App is an Java-Applet. 1. App用C#编写。2. App是Java-Applet。 I want to Copy string from C# App. 我想从C#App复制字符串。 and paste it into focused Textbox in Java-Applet. 并将其粘贴到Java-Applet中的焦点文本框中

I ll copy the string in to Clipboard and I need to Paste it into the focused Textbox in Java-Applet. 我将字符串复制到剪贴板中,然后将其粘贴到Java-Applet中的焦点文本框中。

string data = "12345";
Clipboard.SetData(DataFormats.Text, (Object)data);

Now I need to paste this information into the Textbox in Applet. 现在,我需要将此信息粘贴到Applet的Textbox中。

How can I Call CTRL+V shortcuts in C#? 如何在C#中调用CTRL + V快捷方式?

Is it possible to do something like that? 可以做这样的事情吗?

Thank You! 谢谢!

Another option would be to use InputSimulator which is a very flexible (and reliable) wrapper that is capable of simulating keyboard and mouse events. 另一个选择是使用InputSimulator ,它是一个非常灵活(可靠)的包装程序,能够模拟键盘和鼠标事件。

It wraps SendInput under the hood but abstracts away all the PInvoke calls and other complexity. 它在内部隐藏了SendInput,但抽象了所有PInvoke调用和其他复杂性。 It's a drop in DLL that (for your situation) should only take a couple lines of code. DLL的下降(针对您的情况)仅需要几行代码。

InputSimulator.SimulateKeyDown(VirtualKeyCode.CTRL);
InputSimulator.SimulateKeyPress(VirtualKeyCode.KEYS_V);
InputSimulator.SimulateKeyUp(VirtualKeyCode.CTRL);

or 要么

InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C); 

有关使用SendKeys将击键发送到另一个应用程序的示例,请参见如何:在代码中模拟鼠标和键盘事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM