Widely Vision

  • Real History of Israel

  • Poll

  • Get a PDF version

  • Follow This Blog

  • June 2011
    S M T W T F S
    « Jun   Sep »
     1234
    567891011
    12131415161718
    19202122232425
    2627282930  

How a linux geek play with google guitar

Posted by aboelnour on June 9, 2011

Hi,

I guess you saw the google guitar on google.com

I faced a problem when I try to run the clips which my friends posted on facebook and buzz Because I press keys very slow and I can’t know which clip is this due to the Guitar doesn’t response to the numbers keys which located at the side numpad it only response to the numbers key on the top which I’m not familiar with it. so i wrote this C code to handle my problem and simulate keys pressing :

#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#include <stdio.h>
#include <unistd.h>

int
main (int argc, char *argv[])
{
sleep(2);
Display *display;
unsigned int keycode;
display = XOpenDisplay(NULL);
char* temp = argv[1];

while(*temp != 0)
{
//    printf(“TEST # %d\n”,*temp); //to debug
keycode = XKeysymToKeycode(display, *temp); // get key code

XTestFakeKeyEvent(display, keycode, True, 0); // Generate regular key press
XTestFakeKeyEvent(display, keycode, False, 0);// Generate regular key release
XFlush(display);
temp++;
usleep(500000);
}
return 0;
}

I used the X11 library  to simulate key press and release.

to compile you should link with X11 and Xtst

gcc test.c -lX11 -lXtst

Executable file for linux platforms here.

you should run the code in this format

./test 12-34-454-123

more samples:

‎48-89-89-87-78-78-76-67-6765-4343

2-45-2-45-2-56-12-678-12-678

8786-8786-8786-7-7675-7675-7675-6-6564-6564-6564-5

144-144-345-64-678-654-6564-354

987-67-6-56-7-676-987-7789-7-00-989-878-987

585-3453-12345-975-597-785-23465-321

Now open google.com and your terminal and run the program inside you terminal and quickly make your browser on the top.

best wishes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: