I'm creating a program using gtk and xlib(xtst) to send fake keypresses to an application, I have created this loop to send the keypresses to the active window:
Display *dis;
dis = XOpenDisplay(NULL);
KeyCode modcode = 0; //init value
int i;
char hello[]="hello world";
char temp[1];
int size=sizeof(hello);
sleep(2);
for (i=0;i<size;i++)
{
temp[0]=hello[i];
temp[1]='\0'; //string terminator
g_print("%s\n",temp); //works fine, whitespace is printed
modcode = XKeysymToKeycode(dis, XStringToKeysym(temp));
XTestFakeKeyEvent(dis, modcode, False, 0);
XFlush(dis);
// sleep(1);
XTestFakeKeyEvent(dis, modcode, True, 0);
XFlush(dis);
XTestFakeKeyEvent(dis, modcode, False, 0);
XFlush(dis);
}
problem is it prints 'helloworld' instead, it is incapable of dealing with whitespace or any special characters
thanks
I just created my own translation function as you had suggested:
as for capital letters, I used a shift key with the regular key:
and special characters:
things are working fine now, thanks Ishay