From af542c19827d32a9474a0a41984dd0501e11d698 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Wed, 10 Nov 2010 14:35:04 +0100 Subject: [PATCH] added a Makefile to use it as a C library. no python dependencies. added 2 example programs, which are used by my project df-peek. libxauto.so is emitted. --- Makefile | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ README | 41 +++++------------------------ src/test_findwindow.c | 17 ++++++++++++ src/test_sendtext.c | 27 +++++++++++++++++++ 4 files changed, 122 insertions(+), 35 deletions(-) create mode 100644 Makefile create mode 100644 src/test_findwindow.c create mode 100644 src/test_sendtext.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c93297d --- /dev/null +++ b/Makefile @@ -0,0 +1,72 @@ +# @configure_input@ + +srcdir = src +VPATH = src +package = libxauto +version = 0.2.0 + + +CC = cc +CFLAGS = -Wall +LIBFLAGS = -c +DBGFLAGS = -g + + +all: clean build link +test: clean build_test +#User should not be here, but I don't want this to fail +user_error: + @echo "*** Running the default package in the parent directory ***" + @echo + @$(MAKE) -C .. + +clean: + rm -f *.o *.so + rm -f $(package)_sendtext $(package)_findwindow + +#Compile the source code - DO NOT COMPILE "main.c" - that is a separate test executable +build: + $(CC) $(CFLAGS) $(LIBFLAGS) \ + $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ + $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c \ + -I/usr/include/X11/ \ + -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX + +build_test: + $(CC) $(CFLAGS) $(DBGFLAGS) \ + $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ + $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c $(srcdir)/main.c \ + -I/usr/include/X11/ \ + -lX11 -lXtst \ + -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX \ + -o $(package)_test + +tools: + $(CC) $(CFLAGS) $(DBGFLAGS) \ + $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ + $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c $(srcdir)/test_findwindow.c \ + -I/usr/include/X11/ \ + -lX11 -lXtst \ + -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX \ + -o $(package)_findwindow + $(CC) $(CFLAGS) $(DBGFLAGS) \ + $(srcdir)/xaut.c $(srcdir)/xaut_display.c $(srcdir)/xaut_keyboard.c \ + $(srcdir)/xaut_mouse.c $(srcdir)/xaut_window.c $(srcdir)/test_sendtext.c \ + -I/usr/include/X11/ \ + -lX11 -lXtst \ + -DHAVE_CONFIG_H -DEN_US -DLESS_THAN_FIX \ + -o $(package)_sendtext + +#Link the shared library +link: + ld -shared xaut.o xaut_display.o \ + xaut_keyboard.o xaut_mouse.o xaut_window.o \ + /usr/lib/libX11.so /usr/lib/libXtst.so -o $(package).so + +install: + cp $(srcdir)/xaut.h /usr/include + cp $(srcdir)/xaut_display.h /usr/include + cp $(srcdir)/xaut_keyboard.h /usr/include + cp $(srcdir)/xaut_mouse.h /usr/include + cp $(srcdir)/xaut_window.h /usr/include + diff --git a/README b/README index 91285d4..0e34c5e 100644 --- a/README +++ b/README @@ -1,7 +1,9 @@ -$URL$ -$Author$ -$Date$ -$Rev$ +Note: this is forked from http://sourceforge.net/projects/xautomation + +i basically removed the python dependency and the autoconf stuff that wouldn't +compile on my machine, and adapted the makefile. + +Original Readme starts after this line. === Preamble === This software is intended to help users of XWindows automate basic windowing @@ -26,47 +28,16 @@ Note that Ubuntu (along with some other distributions of Linux) do not come with a development environment installed. You'll need to install a development environment if you do not already have one. -Ubuntu (and similar): - -- build-essential - -Programs: - -- swig - Libraries: -- x11proto-xext-dev -- libx11-dev -- libxtst-dev -Specifically if you are using Ubuntu and wish to compile this software, you can -use the following command: - -$ sudo aptitude install build-essential swig x11proto-xext-dev libx11-dev \ - libxtst-dev - - -=== If you want to modify the build === - -- autoconf - -- automake - -- libtool === What you'll need to run this === -This software was originally written against Python 2.6. It's likely that -there are few (if any) things which will prevent this code from running in -Python 3.x. However, I do not have Python 3.x installed, and cannot test it. To run this software - like say for example you compile it on one machine, and then transport the binary to another machine - make sure you have the following libraries installed: -- libx11-dev -- libxtst-dev - -=== Installing this software === -I highly recommend that you do not install this software. It is simply beyond -my resources to test this software in a wide variety of environments, and it's -likely that automated update tools and the like will cause problems on your -computer if you ignore this advice. Note that there is a "make install" build -target, which is installed for completeness sake, but I suggest you ignore it. - -All you need to do to use this software is make sure that xaut.py and -_xautpy.so are in the same directory as your script. - diff --git a/src/test_findwindow.c b/src/test_findwindow.c new file mode 100644 index 0000000..7189de4 --- /dev/null +++ b/src/test_findwindow.c @@ -0,0 +1,17 @@ +#include "xaut.h" +#include + +int main(int argc, char** argv) { + if (argc < 2) return 1; + + char* title; + if (strcmp(argv[1], "--v") == 0) { + if (argc < 3) return 1; + extra_verbose(1); + title = argv[2]; + } else title = argv[1]; + + Window ret = find_window(title); + printf("%lu\n", *(unsigned long*)&ret); + return 0; +} \ No newline at end of file diff --git a/src/test_sendtext.c b/src/test_sendtext.c new file mode 100644 index 0000000..dbf25f1 --- /dev/null +++ b/src/test_sendtext.c @@ -0,0 +1,27 @@ +#include "xaut.h" +#include + +int main(int argc, char** argv) { + if (argc < 3) return 1; + + char* id_text; + char* send_text; + if (strcmp(argv[1], "--v") == 0) { + if (argc < 4) return 1; + extra_verbose(1); + id_text = argv[2]; + send_text = argv[3]; + } else { + id_text = argv[1]; + send_text = argv[2]; + } + + Window winid = atoi(id_text); + + if(activate_window(winid)) { + sleep(1); + type(send_text); + return 0; + } + return 1; +} \ No newline at end of file -- 2.11.4.GIT