Widely Vision

  • Blog Stats

    • 4,379 hits
  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 7 other followers

  • Blog’s License

    Creative Commons License
  • Recent Comments

    Mina F. Beshay on Google Buzz Analyzer
    Mohamed Ramzy on Google Buzz Analyzer
    Moustafa Mahmoud on Google Buzz Analyzer
    aboelnour on Deeper in Libraries With …
    sigtermer on Deeper in Libraries With …
  • Archives

  • Advertisements
  • Real History of Israel

  • Poll

  • Get a PDF version

  • Follow This Blog

  • June 2011
    S M T W T F S
    « Jun   Sep »

Archive for June, 2011

How a linux geek play with google guitar

Posted by aboelnour on June 9, 2011


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>

main (int argc, char *argv[])
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
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:







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

best wishes.


Posted in C/C++, linux | Leave a Comment »

%d bloggers like this: