howcome@mit-amt.MEDIA.MIT.EDU (Hakon W Lie) (01/23/90)
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. -hakon Hakon W Lie It sometimes howcome@media-lab.media.mit.edu Media Lab, MIT E15-355 happens that people (617) 253-0312 Cambridge, MA 02139 are conservative and USA right at the same time --Wolfgang Kohler
dayglow@csli.Stanford.EDU (Eric T. Ly) (01/24/90)
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
hue@netcom.UUCP (Jonathan Hue) (01/24/90)
In article <11873@csli.Stanford.EDU> dayglow@csli.stanford.edu (Eric T. Ly) writes: >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 ? > >event record and stuff the fields with the appropriate values. Then, >you could just do a [NXApp sendEvent:&theEvent]. Of course, this If you do this you will soon find that you need to use DPSPostEvent() also. The problem is that your app will often go into a loop doing DPSGetEvent() if it gets a mouse-down event on a gadget. So you end up having to shove a bunch of mouse-moves and a mouse up into the event queue with DPSPostEvent() before sending the mouse-down. >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. "help", as Eric knows, consists of a command line option when starting the app. -NXPSName or something like that. -Jonathan
duggie@jessica.Stanford.EDU (Doug Felt) (01/25/90)
In article <11873@csli.Stanford.EDU> dayglow@csli.stanford.edu (Eric T. Ly) writes: >... 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. Actually, DPSPostEvent is one of a small number of routines with the DPS prefix that does not take a context argument. DPSPostEvent only posts to the current event's queue. I myself am also interested in learning how one can post events to another application's event queue. This probably involves security issues, though, so may not be possible (and perhaps should not be). Doug Felt