简体   繁体   English

在C#中模拟X11 KeyPress

[英]Simulate X11 KeyPress in C#

I am using RemoteViewing VNC Server library for .NET to implement some custom VNC behaviour. 我正在使用.NET的RemoteViewing VNC服务器库来实现一些自定义VNC行为。 (Send custom images instead of the desktop under certain conditions etc...) (在某些情况下,请发送自定义图像而不是桌面,等等。)

Now I am adding keyboard functionality, and the library has this keyChange event which provides the X11 KeySym of the key and a boolean indicating wether it is pressed. 现在,我添加了键盘功能,并且该库具有此keyChange事件,该事件提供键的X11 KeySym和一个布尔值,指示是否按下该键。 So I want to fire a function when this event is raised that will pass this key to the local computer. 因此,我想在引发此事件时触发一个函数,它将将此密钥传递给本地计算机。 I am however having a hard time finding a solution that will translate these X11 keysym to something Windows understands. 但是,我很难找到一种解决方案,将这些X11按键符号转换为Windows可以理解的解决方案。

I would really appreciate it if someone could provide some info on how to write the logic that will send these X11 keysyms to Windows. 如果有人可以提供一些有关如何编写将这些X11键符发送到Windows的逻辑的信息,我将非常感激。

Ok, if I understand it right, you just want to translate the X11 KeySymbols to windows keycodes. 好的,如果我理解正确,您只想将X11 KeySymbols转换为Windows键码。 I think you just have to create a dictionary, using as key the values found in keysymdef.h (you've got it here for example) and as values the keycodes understood by SendKeys . 我认为您只需要创建一个字典,使用在keysymdef.h找到的值(例如, 在此处找到它)作为键,并使用SendKeys可以理解的键码作为值。

Hope this puts you on the track. 希望这能使您走上正轨。

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

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