1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| /* it is compatible with latin keyboard */
#include <X11/extensions/XTest.h>
#define XK_LATIN1
#define XK_MISCELLANY
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
Display* pDisplay = XOpenDisplay( NULL );
KeySym key[] = { XK_h,XK_e,XK_l,XK_l,
XK_o,XK_space,XK_w,XK_o,
XK_r,XK_l,XK_d,XK_Return};
int i;
system("gedit");
for( i = 0; i < 13; i++ )
{
XTestFakeKeyEvent ( pDisplay, XKeysymToKeycode( pDisplay, key[i] ),
True, CurrentTime );
}
XTestFakeKeyEvent ( pDisplay, XKeysymToKeycode( pDisplay, key[12] ),
False, CurrentTime );
if( pDisplay == NULL ) return 1;
XCloseDisplay(pDisplay);
return 0;
} |
Partager