VisualNaCro: add sendascii

pull/1/head
dscho 18 years ago
parent a5baf57ba6
commit 5738e33f85

@ -717,6 +717,47 @@ bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown)
return SendKeyEvent(r->client,keysym,keydown); return SendKeyEvent(r->client,keysym,keydown);
} }
bool_t sendascii(resource_t res,const char *string)
{
timeout_t delay = 0.1;
private_resource_t* r=get_resource(res);
int i;
if(r==NULL)
return 0;
while (*string) {
int keysym = *string;
int need_shift = 0;
if (keysym >= 8 && keysym < ' ')
keysym += 0xff00;
else if (keysym >= 'A' && keysym <= 'Z')
need_shift = 1;
else if (keysym > '~') {
fprintf(stderr, "String contains non-ASCII "
"character 0x%02x\n", *string);
return FALSE;
}
if (need_shift) {
if (!SendKeyEvent(r->client,0xffe1,1))
return FALSE;
waitforinput(r,delay);
}
for (i = 1; i >= 0; i--) {
if (!SendKeyEvent(r->client,keysym,i))
return FALSE;
waitforinput(r,delay);
}
if (need_shift) {
if (!SendKeyEvent(r->client,0xffe1,0))
return FALSE;
waitforinput(r,delay);
}
string++;
}
return TRUE;
}
bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons) bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons)
{ {
private_resource_t* r=get_resource(res); private_resource_t* r=get_resource(res);

@ -94,6 +94,7 @@ const char *gettext_server(resource_t res);
/* send events to the server */ /* send events to the server */
bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown); bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown);
bool_t sendascii(resource_t res,const char *string);
bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons); bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons);
bool_t sendtext(resource_t res, const char *string); bool_t sendtext(resource_t res, const char *string);
bool_t sendtext_to_server(resource_t res, const char *string); bool_t sendtext_to_server(resource_t res, const char *string);

Loading…
Cancel
Save