Keys combinations interception



How can i intercept a key pressed in any application and in the X Window
system?  I've already tried gdk_event_get(); but it doesn't work and
i tried also the key snooper but it intercepts only the key on its own
window
I'd like to intercepts a combination of keys (ex: CTRL+k) in all
the X window system like a keylogger Is it possible?

Thanks anyway :-)
I tried  something with this code below, but it is useless for what i want
to do.

#include <stdio.h>
#include <stdlib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>

gint KeySnoopFunc(GtkWidget *grab_widget, GdkEventKey *event, gpointer
func_data)
{
        if(event->type==8)
                //if((GdkEventKey*)evento->type==)             
                  g_print("%s",event->string);
        return FALSE;
}

int main(int argc, char *argv[])
{
        GdkEvent *evento; guint id;
        GtkWidget *window;

        g_print("inizio ");
        gtk_init(&argc,&argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_show (window);
        id=gtk_key_snooper_install(KeySnoopFunc,NULL);
        evento=gdk_event_get();

        if(evento!=NULL)
        {       if(evento->any.type==8)
//if((GdkEventKey*)evento->type==)              
                g_print("Key %s pressed!!/n",evento->key.string);
        gdk_event_free(evento);
        }
        gtk_main();
        
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]