/* $Id: xwarppointer.c,v 1.1 2002/03/01 18:10:35 roderick Exp $ Roderick Schertler */ /* Copyright (C) 2002 Roderick Schertler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This program moves your mouse pointer to the X and Y coordinates given as args. I don't really know anything about X programming. */ #include #include #include #include #include #include int main (int argc, char *argv[]) { Display *dpy; char *arg0; int x = 0, y = 0; arg0 = strrchr (argv[0], '/'); if (arg0) arg0++; else arg0 = argv[0]; if (argc == 2 || argc > 3) { fprintf (stderr, "usage: %s [ ]\n", arg0); exit (1); } if (argc == 3) { char *last_x, *last_y; x = strtoul (argv[1], &last_x, 0); if (*last_x) fprintf (stderr, "%s: invalid x value %s\n", arg0, argv[1]); y = strtoul (argv[2], &last_y, 0); if (*last_y) fprintf (stderr, "%s: invalid y value %s\n", arg0, argv[2]); if (*last_x || *last_y) exit (1); } dpy = XOpenDisplay (NULL); if (!dpy) { fprintf (stderr, "%s: cannot connect to display\n", arg0); exit (1); } XWarpPointer (dpy, None, RootWindow (dpy, DefaultScreen (dpy)), 0, 0, 0, 0, x, y); XCloseDisplay (dpy); return 0; }