产生键盘事件按键 [英] Produce keyboard Events key hits
本文介绍了产生键盘事件按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何制作一个简单的C程序来产生键盘按键.
How to make a simple C program which will produce keyboard key hits.
if ( condition ) {
KeyPress('A');
}
我正在使用Ubuntu 8.10 Linux OS
I am working on Ubuntu 8.10 Linux OS
推荐答案
通过Xdotool获取虚假关键事件
//Compile As: gcc button.c -lX11
#include < X11/Xlib.h >
#include < X11/Xutil.h >
#include < stdio.h >
#include < X11/extensions/XTest.h >
void press_button()
{
Display *d;
d = XOpenDisplay(NULL);
if(d == NULL)
{
//fprintf(stderr, "Errore nell'apertura del Display !!!\n");
//exit(0);
}
system("xdotool key Shift+a");
XFlush(d);
XCloseDisplay(d);
}
int main() {
press_button();
return 0;
}
这篇关于产生键盘事件按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文