Hello All, I am trying to make a program that inserts events into the X-Event queue of a certain program. What i try to do is generate an event and use XSendEvent to transmit it to the currently active window. For some reason however, the program 'xev' shows the events i am transmitting. My own program (and other programs as well !) that i am trying to test do not receive the events transmitted. Here is the code i use to transmit a ButtonPress event : memset(&event,0,sizeof(event)); x=random()%320; y=random()%240; event.type = ButtonPress; event.xbutton.serial=serial++; /* follow up nr but where do i get the current value ? */ event.xbutton.time=0; /* where do i get the time ?? */ event.xbutton.x=x; event.xbutton.y=y; event.xbutton.display=display; event.xbutton.subwindow=InputFocus; event.xbutton.window = InputFocus; /* Is this correct ?? (seems to work) */ event.xbutton.x_root=1; event.xbutton.y_root=1; event.xbutton.same_screen=True; event.xbutton.button=1; event.xbutton.state=0x0; /* what exactly is this state ??? */ printf("Generating event : mouse clicked : %d,%d\n",x,y); res = XSendEvent(display,InputFocus,True,ButtonPressMask,&event); printf("Send event res : %d\n",res); XSync(display,False); NOTE: i am trying to send the output to the window that currently has the focus using the InputFocus window !. Here is a line of output of 'xev' when the program is running and the xev window is in focus : ButtonPress event, serial 27, synthetic YES, window 0x1, root 0x0, subw 0x1, time 0, (234,123), root:(1,1), state 0x0, button 1, same_screen YES Note that the serial number of the packet is numbered up, however i don't know what the start value should be (if there is any). When i fix the serial number to 0 the behaviour of the program stays the same. There are a few other options that i don't know how to set and i don't know if they should be set, these are event.xbutton.time, event.xbutton.time, event.xbutton.state, event.xbutton.button. I don't exactly know what they are used for and i don't know if they have something to do with my problem. So, the problem is : i try to generate ButtonPress events, xev sees the events but other programs don't !. Thanx for any help Grtz Dries Pruimboom -- <End of message> -- <End of message>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 02 June 2003 05:25 pm, dries wrote:
Hello All,
I am trying to make a program that inserts events into the X-Event queue of a certain program. What i try to do is generate an event and use XSendEvent to transmit it to the currently active window.
Check out Xautomation: http://hoopajoo.net/projects/xautomation.html - -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE+211g+FOexA3koIgRAieMAJ0YThNnZjXnLLggKdbL81YNGW8HUQCcCzLo cG+h1AkxwBrKlAoQ4PyOBzo= =CyvD -----END PGP SIGNATURE-----
James Oakley wrote : | -----BEGIN PGP SIGNED MESSAGE----- | Hash: SHA1 | | On Monday 02 June 2003 05:25 pm, dries wrote: | > Hello All, | > | > I am trying to make a program that inserts events into the X-Event queue | > of a certain program. What i try to do is generate an event and use | > XSendEvent to transmit it to the currently active window. | | Check out Xautomation: | | http://hoopajoo.net/projects/xautomation.html | I did, this program uses the Xtest extension, i now do the same, this works more or less perfect ! (within the limits of my expectations). I actually ended up using a program called 'bingo.c' that is a virtual player for some kind of online bingo. just a little adapting (removing about 60% of the program) and it did what i wanted it to do ! Thanx -- <End of message>
participants (2)
-
dries
-
James Oakley