Problem with the XTest extension

Clemens Eisserer linuxhippy at gmail.com
Sun Oct 9 06:49:20 PDT 2005


Hello again,

I am currently experimenting with the XTest extension as well with
xlib a bit and I am still very, very new to xlib and it API so well
... please be a bit patient with me ;)

I wrote a small sample program which just should move the mouse or
emulate some key events, however it does not work and how could it
other be ... I don't know the reason :-(
It would be great if you could give me at least a hint what could be wrong...
I am using xorg-6.8.2 on a Fedora-Core4 box.

(Small question again: How can I map key's to characters?  Are there
any defines in headers or is it possible to get it out of the
key-mapping files?)

Here's the source:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XTest.h>

main(argc,argv)
    int argc;
    char **argv;
{
    Display    *dpy;            /* X server connection */
    int xtest_major_version = 0;
    int xtest_minor_version = 0;
    int dummy;

    /*
     * Open the display using the $DISPLAY environment variable to locate
     * the X server.  See Section 2.1.
     */
    if ((dpy = XOpenDisplay(NULL)) == NULL) {
        fprintf(stderr, "%s: can't open %s\en", argv[0], XDisplayName(NULL));
        exit(1);
    }

    Bool success = XTestQueryExtension(dpy, &dummy, &dummy,
&xtest_major_version, &xtest_minor_version);
    if(success == False || xtest_major_version < 2 ||
(xtest_major_version <= 2 && xtest_minor_version < 2))
    {
        fprintf(stderr,"XTEST extension not supported");
        exit(1);
    }
	
     printf("Bin noch hier!");
     XTestFakeKeyEvent(dpy, 65, True, 0);	
     XTestFakeKeyEvent(dpy, 65, False, 0);	
     XTestFakeMotionEvent(dpy, -1, 200, 200, 0);

  return 0;
}



More information about the xorg mailing list