Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!elroy.jpl.nasa.gov!decwrl!shelby!csli!dayglow From: dayglow@csli.Stanford.EDU (Eric T. Ly) Newsgroups: comp.sys.next Subject: Re: Fake events Keywords: fake event FrameMaker Message-ID: <11873@csli.Stanford.EDU> Date: 23 Jan 90 20:39:42 GMT References: <1465@mit-amt.MEDIA.MIT.EDU> Sender: dayglow@csli.Stanford.EDU (Eric T. Ly) Reply-To: dayglow@csli.stanford.edu (Eric T. Ly) Organization: Center for the Study of Language and Information, Stanford U. Lines: 47 In article <1465@mit-amt.MEDIA.MIT.EDU> howcome@mit-amt.MEDIA.MIT.EDU (Hakon W Lie) writes: >I am trying to port an application from sun/x-windows to NeXT. In X11 >I can send generate events (like keyclicks, buttonpresses etc.) >through XSendEvent. Is something similar possible on the NeXT ? > >The reason why I want to do this is to be able to use applications >non-interactively, e.g. print a document in FrameMaker through a >command to the shell, not through a series of clicks. There is a distinction that needs to be made here, and that is whether you want to send an event from within your own application, or whether you want to send an event to another application. The first can be done with some amount of hacking; the second is nearly impossible (I think). If you want to do the first, then the best thing to do is allocate an event record and stuff the fields with the appropriate values. Then, you could just do a [NXApp sendEvent:&theEvent]. Of course, this assumes that you know the fields and their functionality very well, so you might have to investigate. In fact, the best thing to do is to encapsulate this functionality into a class (call it EventMaker or something) so that you can send messages to it requesting various kinds of prepackaged events. If you want the second, the problem gets much harder. The only call that I know of that'll let you do post an event to another DPS context is DPSPostEvent(), but this call requires a DPSContext argument of the application you intend to send the event to. This means that you somehow have to get the DPSContext value of the other application, which doesn't seem possible at the moment without the cooperation of the other application. Also, the DPSContext is a pointer to some struct in C, so it may not point to the same thing in different memory spaces. Of course, you can skip all the DPS client library stuff and go all the way down to the level of Mach messaging, sending an event to the desired application as if you were the Window Server, but this also requires that you find the correct Mach port to which to send events and that you have send rights to it, none of which seems possible without the help of the other application. Well, this is what I know from past experience and off the top of my head. Eric Ly CSLI, Stanford University