2 # -*- coding: utf-8 -*-
3 """Test program to see if XTables.py will correctly id the poker client.
5 # Copyright 2010-2011, Ray E. Barker
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # ====EXAMPLE OUTPUT FROM MY SYSTEM====
22 #enter table xid find (in hex):
23 #0x3600018 <---GET THIS BY RUNNING xwininfo FROM A TERMINAL.
24 #Window information from xwininfo:
25 #-------------------------------------------------------
27 #xwininfo: Window id: 0x3600018 "Baseline Rd(26128925) - $100/$200 - Limit Hold'em"
29 # Root window id: 0x107 (the root window) (has no name)
30 # Parent window id: 0xe6e0a2 (has no name)
32 # 0x3600019 (has no name): () 792x573+0+0 +2171+192
35 #-------------------------------------------------------
38 #Window information from functions:
40 #window = Xlib.display.Window(0x03600018) title = "Baseline Rd(26128925) - $100/$200 - Limit Hold'em"
42 #parent = Xlib.display.Window(0x00e6e0a2)
48 # Other Library modules
51 disp
= Xlib
.display
.Display()
52 root
= disp
.screen().root
53 name_atom
= disp
.get_atom("WM_NAME", 1)
55 def get_window_from_xid(id):
56 for outside
in root
.query_tree().children
:
58 print "matched outside"
60 for inside
in outside
.query_tree().children
:
62 print "matched inside"
66 def get_window_title(xid
):
67 s
= os
.popen("xwininfo -children -id %d" % xid
).read()
68 mo
= re
.search('"(.+)"', s
)
71 except AttributeError:
74 if __name__
== "__main__":
76 print "enter table xid find (in hex): "
77 xid
= sys
.stdin
.readline()
79 print "Window information from xwininfo:"
80 s
= os
.popen("xwininfo -children -id %d" % int(xid
, 0)).read()
81 print "-------------------------------------------------------"
83 print "-------------------------------------------------------\n\n"
85 print "Window information from functions:"
86 window
= get_window_from_xid(int(xid
, 0))
87 print "window =", window
, "title = \"" + get_window_title(int(xid
, 0)) + "\"\n"
89 print "parent =", window
.query_tree().parent