Guest User

Untitled

a guest
Jan 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #! /usr/bin/env python
  2. import sys
  3. from ctypes import *
  4. Xlib = CDLL("libX11.so.6")
  5. display = Xlib.XOpenDisplay(None)
  6. if display == 0: sys.exit(2)
  7. w = Xlib.XRootWindow(display, c_int(0))
  8. (root_id, child_id) = (c_uint32(), c_uint32())
  9. (root_x, root_y, win_x, win_y) = (c_int(), c_int(), c_int(), c_int())
  10. mask = c_uint()
  11. ret = Xlib.XQueryPointer(display, c_uint32(w), byref(root_id), byref(child_id),
  12. byref(root_x), byref(root_y),
  13. byref(win_x), byref(win_y), byref(mask))
  14. if ret == 0: sys.exit(1)
  15. print child_id.value
  16.  
  17. xwininfo -tree -id $(XQueryPointer)
  18.  
  19. % xwininfo
  20. xwininfo: Please select the window about which you
  21. would like information by clicking the
  22. mouse in that window.
  23.  
  24. xwininfo: Window id: 0xa0000d "flask"
  25.  
  26. ...
  27.  
  28. xdotool getmouselocation --shell | grep WINDOW
  29.  
  30. sedGetValue='s/.*=(.*)/1/'
  31. windowId=`xdotool getmouselocation --shell 2>/dev/null |grep WINDOW |sed "$sedGetValue"`
  32. echo $windowId
  33.  
  34. xdotool click 1|xwininfo|grep 'Window id:'
  35.  
  36. activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
  37. activeWinId=${activeWinLine:40}
  38.  
  39. activeWin="$(xprop -root | sed -n 's/^_NET_ACTIVE_WINDOW(WINDOW): window id # //p')"
  40.  
  41. activeWin="$(xprop -root)"
  42. activeWin="${activeWin#*_NET_ACTIVE_WINDOW(WINDOW):}'
  43. activeWin="${activeWin%%?_NET_*}'
  44. activeWin="${activeWin##* }'
  45.  
  46. xprop -root 2>/dev/null | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* // p'
  47.  
  48. from Xlib.display import Display
  49.  
  50. display = Display()
  51. window = display.screen().root
  52. result = window.query_pointer()
  53.  
  54. print(result.child.id)
Add Comment
Please, Sign In to add comment