On Fri, Jul 18, 2003 at 12:28:46PM -0700, Jeremy C. Reed wrote:
> I recall someone mentioning on the list about a software that could be
> programmed to simulate pointer movements and clicks.
>
xwarppointer.c (attached, 5k) was mentioned. i dont recall if a url was
given to point to this file, and the header on it doesnt mention a
source website. i found similar things via google, but not the same one.
xbut was also mentioned at some point (i believe the same thread) for
generating button events. the readme cites http://www.sandklef.com/xbut/
as it's home.
Russ
--
=======================================================================
| Russ Burdick | "What do the good know...except what the |
|=============== bad teach them by their excesses?" -Clive Barker |
| [EMAIL PROTECTED] http://extrapolation.net |
=======================================================================
/*
* Simple util to move the X cursor around from the command line.
* By �ric Tremblay <[EMAIL PROTECTED]>
*
* To compile and install:
* gcc -L /usr/X11/lib -lX11 xwarppointer.c -o /usr/local/bin/xwarppointer
*
* Legalese (i think):
* THIS PROGRAM IS HEREBY RELEASED TO THE PUBLIC DOMAIN, THEREFORE
* ANYONE ANYWHERE IN THE UNIVERSE OR OTHER LOCATIONS MAY DO WHATEVER HE,
* SHE, OR IT WANTS WITH THIS CODE.
* THE AUTHOR (that's me) WILL NOT BE HELD RESPONSIBLE FOR ANY DAMAGE,
* INCONVENIENCE, ADDICTION, HEART OR LUNG DISEASE, IMPOTENCE, MIGRAINE,
* MENTAL ILLNESS, TORNADOES, EARTHQUAKES, TOTAL EXTINCTION OF LIFE ON EARTH
* OR OTHER BAD THINGS THAT MIGHT BE CAUSED BY THE USE OF THIS PROGRAM.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#define VERSION_STRING "xwarppointer version 0.001"
#define debug_printf /* */
/* #define debug_printf printf /* */
int isnum (char *str);
void usage (int argc, char *argv []);
void query (Display *dpy, Window w);
int main (int argc, char *argv [])
{
Display *dpy;
Window rootwindow;
int x, y, w, h, i;
int relative = 0;
int xarg = -1;
int sarg = -1;
long int sleeptime = 0;
if (argc < 2)
{
debug_printf ("usage from argc < 2 check\n");
usage (argc, argv);
} /* if */
dpy = XOpenDisplay (NULL);
if (!dpy)
{
fprintf (stderr, "Couldn't open X display.\n");
exit (1);
} /* if */
rootwindow = DefaultRootWindow (dpy);
/* parse command line */
for (i = 1; i < argc; i++)
{
debug_printf ("Parsing arg %d of %d '%s'\n", i, argc, argv [i]);
/* request version info? */
if (strstr (argv [i], "-v"))
{ printf ("%s\n", VERSION_STRING); exit (0); }
/* request usage? */
else if (strstr (argv [i], "-h"))
{ debug_printf ("Usage from -h\n"); usage (argc, argv); }
/* relative placement? */
else if (strstr (argv [i], "-r"))
relative = 1;
/* query? */
else if (strstr (argv [i], "-q"))
query (dpy, rootwindow);
/* sleeptime? */
else if (strstr (argv [i], "-s"))
{
if (argc <= i + 1)
{
debug_printf ("Usage from -s arg check\n");
usage (argc, argv);
} /* if */
sarg = ++i;
debug_printf ("sleeptime will be arg %d '%s'\n", i, argv [sarg]);
if (!isnum (argv [sarg]))
{
debug_printf ("usage from -s parameter not being a number\n");
usage (argc, argv);
} /* if */
sleeptime = atol (argv [sarg]);
} /* else if */
/* number? */
else if (isnum (argv [i]))
{
debug_printf ("Determined arg %d '%s' will be X\n", i, argv [i]);
if (argc <= i + 1)
{ debug_printf ("Usage from isnum arg check\n"); usage (argc, argv); }
xarg = i;
debug_printf ("arg %d '%s' is X\n", i, argv [i]); x = atoi (argv [i++]);
debug_printf ("arg %d '%s' is Y\n", i, argv [i]); y = atoi (argv [i]);
} /* this is the arg for 'x' */
/* don't know wtf is this arg */
else
{
printf ("What is a '%s' ???\n\n", argv [i]);
debug_printf ("Usage from fallback else");
usage (argc, argv);
} /* else */
} /* for */
if (xarg == -1)
usage (argc, argv);
/* sleeptime = atol (argv [sarg]);
x = atoi (argv [xarg]);
y = atoi (argv [xarg + 1]); */
if (x < 0 && !relative) x = DisplayWidth (dpy, DefaultScreen (dpy)) + x;
if (y < 0 && !relative) y = DisplayHeight (dpy, DefaultScreen (dpy)) + y;
XWarpPointer (dpy, rootwindow,
(relative ? 0 : rootwindow),
0, 0,
0, 0,
x, y);
XCloseDisplay (dpy);
debug_printf ("sleeptime == %d\n", (int) sleeptime);
if (sleeptime)
usleep ((unsigned long int) sleeptime * 1000);
exit (0);
return 0;
} /* main () */
/* checks if string *str is a number */
int isnum (char *str)
{
int result = 1,
i = 0;
for (; str [i]; i++)
{
/* debug_printf ("Checking %c\n", str [i]); */
if (!strchr ("-0123456789", str [i]))
{
result = 0;
} /* if */
} /* for */
/* printf ("isnum: checked %s, returned %d\n", str, result); */
return result;
} /* isnum */
/* Displays quick usage info */
void usage (int argc, char *argv [])
{
printf ("Usage: %s [options] <x> <y>\n\n"
" Options:\n"
" -r or --relative Move relative from current position\n"
" -q or --query Report pointer position\n"
" -s or --sleep <n> Sleep <n> milliseconds after moving mouse poin
ter\n"
" -v or --version Duh\n"
" -h or --help Duh\n\n",
argv [0]);
exit (1);
} /* usage () */
/* Checks pointer coords and prints them to stdout */
void query (Display *dpy, Window w)
{
int x, y, dummy;
XQueryPointer (dpy, w, &w, &w,
&x, &y,
&dummy, &dummy,
&dummy);
printf ("%d %d\n", x, y);
exit (0);
} /* query () */
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
List archives: http://asgardsrealm.net/lurker/splash/index.html
Trouble? Contact [EMAIL PROTECTED]