Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- import sys
- from ctypes import *
- Xlib = CDLL("libX11.so.6")
- display = Xlib.XOpenDisplay(None)
- if display == 0: sys.exit(2)
- w = Xlib.XRootWindow(display, c_int(0))
- (root_id, child_id) = (c_uint32(), c_uint32())
- (root_x, root_y, win_x, win_y) = (c_int(), c_int(), c_int(), c_int())
- mask = c_uint()
- ret = Xlib.XQueryPointer(display, c_uint32(w), byref(root_id), byref(child_id),
- byref(root_x), byref(root_y),
- byref(win_x), byref(win_y), byref(mask))
- if ret == 0: sys.exit(1)
- print child_id.value
- xwininfo -tree -id $(XQueryPointer)
- % xwininfo
- xwininfo: Please select the window about which you
- would like information by clicking the
- mouse in that window.
- xwininfo: Window id: 0xa0000d "flask"
- ...
- xdotool getmouselocation --shell | grep WINDOW
- sedGetValue='s/.*=(.*)/1/'
- windowId=`xdotool getmouselocation --shell 2>/dev/null |grep WINDOW |sed "$sedGetValue"`
- echo $windowId
- xdotool click 1|xwininfo|grep 'Window id:'
- activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
- activeWinId=${activeWinLine:40}
- activeWin="$(xprop -root | sed -n 's/^_NET_ACTIVE_WINDOW(WINDOW): window id # //p')"
- activeWin="$(xprop -root)"
- activeWin="${activeWin#*_NET_ACTIVE_WINDOW(WINDOW):}'
- activeWin="${activeWin%%?_NET_*}'
- activeWin="${activeWin##* }'
- xprop -root 2>/dev/null | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* // p'
- from Xlib.display import Display
- display = Display()
- window = display.screen().root
- result = window.query_pointer()
- print(result.child.id)
Add Comment
Please, Sign In to add comment