From d0acf8e94354b0fc094abc8ec427e0d9555a767d Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Fri, 4 Mar 2011 08:46:41 -0500 Subject: [PATCH] WinTables: ignore tables that are not visible, have parents, or appear to be other non-app styled windows --- pyfpdb/WinTables.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index 599e51c6..5b3b4a54 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -56,12 +56,23 @@ class Table(Table_Window): """Finds poker client window with the given table name.""" titles = {} win32gui.EnumWindows(win_enum_handler, titles) - for hwnd in titles: + for hwnd in titles: if titles[hwnd] == "": continue if re.search(self.search_string, titles[hwnd], re.I): if self.check_bad_words(titles[hwnd]): continue + if not win32gui.IsWindowVisible(hwnd): # if window not visible, probably not a table + continue + if win32gui.GetParent(hwnd) != 0: # if window is a child of another window, probably not a table + continue + HasNoOwner = win32gui.GetWindow(hwnd, win32con.GW_OWNER) == 0 + WindowStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) + if HasNoOwner and WindowStyle & win32con.WS_EX_TOOLWINDOW != 0: + continue + if not HasNoOwner and WindowStyle & win32con.WS_EX_APPWINDOW == 0: + continue + self.window = hwnd break