简体   繁体   English

使用X11(GTK,GDK)功能从C发送键组合

[英]Send key combination from C using X11 (GTK, GDK) functions

I need exact equivalent of command (in C code) 我需要完全等效的命令(在C代码中)

system("xdotool key alt+o");

but much more portable (and less overloaded for so simple task). 但具有更多的可移植性(并且对于如此简单的任务而言,过载程度较小)。 I write for GTK so i prefer some GTK function, but something for GDK or even for X11 also looks to be portable. 我是为GTK编写的,所以我更喜欢一些GTK功能,但是GDK甚至X11的东西看起来也很便携。 Thanks. 谢谢。

Here's an example that does what you want: 这是一个满足您需求的示例:

http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html

It's command-line, but it's short and it's pretty easy to understand so turning it into something your code can call should be easy. 它是命令行,但是很简短,而且很容易理解,因此将其转换为代码可以调用的东西应该很容易。

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

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