ADAM'S WEB PRESENCE

3 February 2008

Mud Soup

Filed under: Bizarre Stuff, Homemade Creations — adam @ 4:08 pm

mudsoup.pngIts nice to know that while I was obsessing over my circuit board, the kids were busy making stuff too. A wonderful Mudistrone Soup!

They are so proud of it.


2 December 2007

Trolleys

Filed under: Bizarre Stuff — adam @ 9:04 pm

Here are some shopping trolleys waiting for the bus. I wonder where they are going ?Bus Trolleys


3 January 2007

Turtle Boy

Filed under: Bizarre Stuff — adam @ 9:37 pm

Turle Boy!


Boing Cars

Filed under: Bizarre Stuff — adam @ 8:09 am

Boing ballsAm I too much of a nerd ? Or too much of an Amiga fan ? Well, whatever the case, I really got a laugh out of this car dealer with the boing balls everywhere.


10 October 2006

Sending fake keypress events to an X11 window

Filed under: Bizarre Stuff, Nerd Notes — adam @ 12:43 pm

This C++ example code will send a cursor-down event to the currently focussed window. It can easily be modified to send other key events. It would be a good starting point to write a virtual keyboard or remote control application.

// Send a fake keystroke event to an X window.
// by Adam Pierce - http://www.doctort.org/adam/
// This is public domain software. It is free to use by anyone for any purpose.

#include <X11/Xlib.h>
#include <X11/keysym.h>

// The key code to be sent.
// A full list of available codes can be found in /usr/include/X11/keysymdef.h
#define KEYCODE XK_Down

// Function to create a keyboard event
XKeyEvent createKeyEvent(Display *display, Window &win,
                           Window &winRoot, bool press,
                           int keycode, int modifiers)
{
   XKeyEvent event;

   event.display     = display;
   event.window      = win;
   event.root        = winRoot;
   event.subwindow   = None;
   event.time        = CurrentTime;
   event.x           = 1;
   event.y           = 1;
   event.x_root      = 1;
   event.y_root      = 1;
   event.same_screen = True;
   event.keycode     = XKeysymToKeycode(display, keycode);
   event.state       = modifiers;

   if(press)
      event.type = KeyPress;
   else
      event.type = KeyRelease;

   return event;
}

main()
{
// Obtain the X11 display.
   Display *display = XOpenDisplay(0);
   if(display == NULL)
      return -1;

// Get the root window for the current display.
   Window winRoot = XDefaultRootWindow(display);

// Find the window which has the current keyboard focus.
   Window winFocus;
   int    revert;
   XGetInputFocus(display, &winFocus, &revert);

// Send a fake key press event to the window.
   XKeyEvent event = createKeyEvent(display, winFocus, winRoot, true, KEYCODE, 0);
   XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);

// Send a fake key release event to the window.
   event = createKeyEvent(display, winFocus, winRoot, false, KEYCODE, 0);
   XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);

// Done.
   XCloseDisplay(display);
   return 0;
}

To compile it, you need to type this:

g++ -o XFakeKey XFakeKey.cpp -L/usr/X11R6/lib -lX11

23 September 2006

Cheap Batteries

Filed under: Bizarre Stuff — adam @ 12:54 am

Really cheap batteriesI bought some AAA batteries, $2 for a pack of 24. At that price you just know they have to suck.

Check out the colour scheme. We wouldn’t be trying to imitate a well known battery brand here by any chance ?

And look! they even have a fake battery tester strip. It’s just printed on the side.

And no, they did not last very long. I don’t think they are even alkalines.


17 September 2006

Dumb Remote Controls part 2

Filed under: Bizarre Stuff, General — adam @ 1:39 pm

Quick, the boss is coming!If that last remote control wasn’t stupid enough for you, look at this one. It has a Boss Key !


5 July 2006

Press any key to continue…

Filed under: Bizarre Stuff, General — adam @ 12:02 pm

The Any KeyThe designers of this DVD player have stepped over the line with this one! What will be next, an “RTFM” button ?


Powered by WordPress