Advertisement
Guest User

Untitled

a guest
Jan 13th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import gtk.gdk
  2. from subprocess import call
  3. from time import sleep
  4.  
  5. def pixel_at(x, y):
  6. rw = gtk.gdk.get_default_root_window()
  7. pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 1, 1)
  8. pixbuf = pixbuf.get_from_drawable(rw, rw.get_colormap(), x, y, 0, 0, 1, 1)
  9. return tuple(pixbuf.pixel_array[0, 0])
  10.  
  11.  
  12. sleep(2)
  13. for i in range(600):
  14. sleep(0.2)
  15. pix=pixel_at(2430,587)
  16. if pix==(207,58,0):
  17. key='Right'
  18. elif pix==(192,149,3):
  19. key='Down'
  20. elif pix==(157,2,227):
  21. key='Up'
  22. elif pix==(0,29,55):
  23. key='Left'
  24. else:
  25. key=''
  26. xdotool="xdotool key " + key
  27. if key!='':
  28. call(xdotool, shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement