基于GTK 与 Fakekey(将模拟键盘与PC机键盘链接在一起)
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <fakekey/fakekey.h>
#include <X11/keysym.h>
Display* disp ;
FakeKey *fk;
GtkWidget *win = NULL;
static char *numkeyboard_display[]=
{
"1\0", "2\0", "3\0", "+","4\0", "5\0", "6\0","-", "7\0", "8\0", "9\0", ".", "0\0", "←\0", "→\0", "Backspace\0", "Delete\0", "Enter\0"
};
static gushort numkeyboard_send[] =
{
XK_1, XK_2, XK_3, XK_plus, XK_4, XK_5, XK_6, XK_minus, XK_7, XK_8, XK_9, XK_period, XK_0, XK_Left, XK_Right, XK_BackSpace, XK_Delete, XK_Return
};
gboolean numbt_release (GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
gint i = GPOINTER_TO_UINT(user_data);
fakekey_press_keysym(fk, numkeyboard_send[i], 0);
fakekey_release(fk);
return TRUE;
}
void clicked_callback(GtkButton *button1, GtkWindow *window)
{
gint j;
GtkWidget *butto

这篇博客介绍了如何在Linux环境下利用GTK库结合Fakekey工具,实现模拟键盘输入的功能。通过编译并运行包含GTK2.0接口的C语言程序,可以将模拟的键盘事件与PC键盘相连接。

884

被折叠的 条评论
为什么被折叠?



