home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / 17907 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  1.5 KB

  1. Path: sparky!uunet!gatech!news.ans.net!cmcl2!adm!news
  2. From: leec@leland.stanford.edu (Christopher Lee)
  3. Newsgroups: comp.sys.sgi
  4. Subject: how to send KeyEvents to xwsh on SGI?
  5. Message-ID: <34592@adm.brl.mil>
  6. Date: 12 Dec 92 13:17:31 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 35
  9.  
  10. I want to use the Xlib SendEvent() call to send text to an xwsh, such
  11. that xwsh interprets this just as if a user had typed the text in the xwsh.
  12. I have tried the obvious... and it indeed works sending text to my own
  13. X applications, but not to xwsh!  Here is the basic idea of what I've
  14. tried:
  15.  
  16.   XKeyEvent xpress={KeyPress},xrel={KeyRelease};
  17.   dpy=XOpenDisplay(0);
  18.   if (!dpy) {
  19.     fprintf(stderr, "No connection to X server, check setting of environment's \\$DISPLAY.\n");
  20.     exit(-1);
  21.   }
  22.  
  23.   xpress.display=xrel.display=dpy;
  24.   xpress.window=xrel.window=xpress.root=xrel.root=
  25.     xpress.subwindow=xrel.subwindow=target;
  26.  
  27.   while (EOF!=(i=getchar())) {
  28.     xpress.keycode=xrel.keycode=XKeysymToKeycode(dpy,(KeySym)i);
  29.     XSendEvent(dpy,target,False,0,&xpress);  /* PRESS THE KEY */
  30.     XSendEvent(dpy,target,False,0,&xrel);  /* RELEASE IT*/
  31.     XFlush(dpy);
  32.   }
  33.  
  34. Do I need to do some fancy setting of the XKeyEvent member data to convince
  35. xwsh that the event should really be paid attention to?  Do the .x .y fields
  36. matter?  etc.
  37.  
  38. What I am *really* trying to do is be able to pipe input to drive a terminal
  39. just as if a user had typed some commands.  Any advice on this would be
  40. appreciated!
  41.  
  42. Thanks!
  43.  
  44. Chris Lee
  45.