#include #include #include GdkWindow* gSuperWindow; static gboolean press_key (gpointer data) { GdkWindow *window; GdkModifierType NO_MODIFIER = (GdkModifierType) 0; int* c = (int *) data; window = gdk_get_default_root_window(); gdk_test_simulate_key (gSuperWindow, -1, -1, GDK_KEY_a, NO_MODIFIER, GDK_KEY_PRESS); gdk_test_simulate_key (gSuperWindow, -1, -1, GDK_KEY_a, NO_MODIFIER, GDK_KEY_RELEASE); (*c)++; printf("Char printed\n"); if (*c < 10) { return TRUE; } else { return FALSE; } } static void activate (GApplication* app) { GtkWidget* window; GtkWidget* text; window = gtk_application_window_new (GTK_APPLICATION (app)); text = gtk_entry_new (); gtk_container_add (GTK_CONTAINER (window), text); gtk_widget_show_all (window); gSuperWindow = gtk_widget_get_window (window); g_timeout_add (500, press_key, new int {0}); } int main(int argc, char** argv) { GtkApplication* app; int status; app = gtk_application_new ("linuxrc.eric", G_APPLICATION_FLAGS_NONE); g_signal_connect (app, "activate", G_CALLBACK (activate), app); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); return status; }