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
36
37
38
39
|
#include "keyboard_writer.h"
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
int x11_key(char *zh){
Display *dpy;
dpy = XOpenDisplay(NULL);
KeySym sym = XStringToKeysym(zh);
KeyCode code = XKeysymToKeycode(dpy,sym);
XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);
XFlush( dpy );
XCloseDisplay( dpy );
return 0;
}
int x11_key_shift(char *zh){
Display *dpy;
dpy = XOpenDisplay(NULL);
KeySym sym = XStringToKeysym(zh);
KeyCode code = XKeysymToKeycode(dpy,sym);
XTestFakeKeyEvent(dpy, 50, True, 1);
XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);
XTestFakeKeyEvent(dpy, 50, False, 1);
XFlush( dpy );
XCloseDisplay( dpy );
return 0;
}
|