python-xlib question
- From: giovanni.iovino@xxxxxxxxx
- Date: Sun, 16 Dec 2007 03:30:28 -0800 (PST)
Hi,
sorry for my English.
I'm writing my first python script for Linux for a remote bluetooth
application.
I'm using python-xlib library to send keyboard and mouse events and at
the moment
I can send keyboard emulated input to the window where pointer is on,
i can also move the pointer over the
desktop.
I'm using python 2.5 on a Ubuntu 7.10 system with gnome and compiz
However the method fails when i try to emulate mouse clicks
Here follows the code I'm using, if you change ButtonPress and
ButtonRelease with KeyPress and KeyRelease and change the detail of
ev_d it works
####################################################################################
#!/usr/bin/env python
import Xlib.display
import Xlib.X
import Xlib.XK
import Xlib.error
import time
display = Xlib.display.Display()
screen = display.screen()
root = screen.root
pointer=root.query_pointer() #Get info like window where pointer is on
and pointer position
window=pointer.child
ev_d = dict(
time = 0, # Time of the event (useful for double-
clicks for mouse
events)
root = root,
window = pointer.child, #The window where is the
pointer
same_screen = 1,
child = Xlib.X.NONE,
root_x = pointer.root_x,
root_y = pointer.root_y,
event_x = pointer.win_x,
event_y = pointer.win_y,
state = Xlib.X.NONE,
detail =Xlib.X.Button1
)
ev2_dict = ev_d.copy()
ev2_dict['state'] = Xlib.X.Button1 << 8 # that is ButtonXMask
ev=Xlib.protocol.event.ButtonPress(**ev_d)
ev2=Xlib.protocol.event.ButtonRelease(**ev2_dict)
display.send_event(Xlib.X.PointerWindow,ev)
display.sync() # Send the inserted events
time.sleep(500/1000)
display.send_event(Xlib.X.PointerWindow,ev2)
display.sync()
#################################################################
Thanks to who wants help me
Bye,
Giovanni
.
- Follow-Ups:
- Re: python-xlib question
- From: giovanni . iovino
- Re: python-xlib question
- Prev by Date: Re: Good native Linux text editors ???
- Next by Date: Re: Help: Segmentation fault
- Previous by thread: Hiding template and instantiated template symbols
- Next by thread: Re: python-xlib question
- Index(es):
Relevant Pages
|