#include #include #include #include #include #include #include #include #include static PyObject * key_makeev(PyObject *self, PyObject *args) { Display *pDisplay = NULL; int LocalScreen; KeyCode kc; int code; int sts; // unsigned long wind; // // unsigned long time; // // int rev_to; // if (!PyArg_ParseTuple(args, "i", &code)) return NULL; pDisplay = XOpenDisplay(NULL); printf ("pDisplay = %lX\n", (long)pDisplay); LocalScreen = DefaultScreen(pDisplay); XSync(pDisplay,1); /* XGetInputFocus(pDisplay, &wind, &rev_to); // printf ("Window = %lX rev_to = %d\n", wind, rev_to); //*/ kc = XKeysymToKeycode(pDisplay, code); XTestFakeKeyEvent(pDisplay, kc, True, 10); XTestFakeKeyEvent(pDisplay, kc, False, 10); // XTestFakeMotionEvent(pDisplay, 0, 10, 10, 10); // XTestFakeButtonEvent(pDisplay, 1, True, 10); // XTestFakeButtonEvent(pDisplay, 1, False, 10); XFlush(pDisplay); XCloseDisplay(pDisplay); //XTestFakeKeyEvent(display, 51, True, 0); //XTestFakeKeyEvent(display, 51, False, 0); //printf("%d\n", code); sts = 0; return Py_BuildValue("i", sts); } static PyMethodDef KeyMethods[] = { {"makeev", key_makeev, METH_VARARGS, "Gera key events."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; PyMODINIT_FUNC initkey(void) { (void) Py_InitModule("key", KeyMethods); }