stuck an error print in wintables if self.window doesn't exist
This commit is contained in:
parent
32e7a28d2c
commit
a735ab67b2
|
@ -9,12 +9,12 @@ Routines for detecting and handling poker client windows for MS Windows.
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
@ -56,9 +56,13 @@ class Table(Table_Window):
|
||||||
if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
|
if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
|
||||||
self.window = hwnd
|
self.window = hwnd
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.window == None:
|
try:
|
||||||
print "Window %s not found. Skipping." % search_string
|
if self.window == None:
|
||||||
|
print "Window %s not found. Skipping." % search_string
|
||||||
|
return None
|
||||||
|
except AttributeError:
|
||||||
|
print "self.window doesn't exist? why?"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
|
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
|
||||||
|
@ -70,7 +74,7 @@ class Table(Table_Window):
|
||||||
print "x = %s y = %s width = %s height = %s" % (self.x, self.y, self.width, self.height)
|
print "x = %s y = %s width = %s height = %s" % (self.x, self.y, self.width, self.height)
|
||||||
#self.height = int(height) - b_width - tb_height
|
#self.height = int(height) - b_width - tb_height
|
||||||
#self.width = int(width) - 2*b_width
|
#self.width = int(width) - 2*b_width
|
||||||
|
|
||||||
self.exe = self.get_nt_exe(hwnd)
|
self.exe = self.get_nt_exe(hwnd)
|
||||||
self.title = titles[hwnd]
|
self.title = titles[hwnd]
|
||||||
self.site = ""
|
self.site = ""
|
||||||
|
@ -99,37 +103,37 @@ class Table(Table_Window):
|
||||||
|
|
||||||
def get_nt_exe(self, hwnd):
|
def get_nt_exe(self, hwnd):
|
||||||
"""Finds the name of the executable that the given window handle belongs to."""
|
"""Finds the name of the executable that the given window handle belongs to."""
|
||||||
|
|
||||||
# Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
|
# Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
|
||||||
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
|
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
|
||||||
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
|
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
|
||||||
# enable "debug process"
|
# enable "debug process"
|
||||||
privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
|
privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
|
||||||
old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
|
old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
|
||||||
|
|
||||||
# Open the process, and query it's filename
|
# Open the process, and query it's filename
|
||||||
processid = win32process.GetWindowThreadProcessId(hwnd)
|
processid = win32process.GetWindowThreadProcessId(hwnd)
|
||||||
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
|
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
|
||||||
exename = win32process.GetModuleFileNameEx(pshandle, 0)
|
exename = win32process.GetModuleFileNameEx(pshandle, 0)
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
win32api.CloseHandle(pshandle)
|
win32api.CloseHandle(pshandle)
|
||||||
win32api.CloseHandle(hToken)
|
win32api.CloseHandle(hToken)
|
||||||
|
|
||||||
return exename
|
return exename
|
||||||
def topify(self, hud):
|
def topify(self, hud):
|
||||||
"""Set the specified gtk window to stayontop in MS Windows."""
|
"""Set the specified gtk window to stayontop in MS Windows."""
|
||||||
|
|
||||||
# def windowEnumerationHandler(hwnd, resultList):
|
# def windowEnumerationHandler(hwnd, resultList):
|
||||||
# '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
|
# '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
|
||||||
# resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
|
# resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
|
||||||
#
|
#
|
||||||
# unique_name = 'unique name for finding this window'
|
# unique_name = 'unique name for finding this window'
|
||||||
# real_name = hud.main_window.get_title()
|
# real_name = hud.main_window.get_title()
|
||||||
# hud.main_window.set_title(unique_name)
|
# hud.main_window.set_title(unique_name)
|
||||||
# tl_windows = []
|
# tl_windows = []
|
||||||
# win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
|
# win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
|
||||||
#
|
#
|
||||||
# for w in tl_windows:
|
# for w in tl_windows:
|
||||||
# if w[1] == unique_name:
|
# if w[1] == unique_name:
|
||||||
# hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
|
# hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
|
||||||
|
@ -139,14 +143,13 @@ class Table(Table_Window):
|
||||||
(innerx, innery) = self.gdkhandle.get_origin()
|
(innerx, innery) = self.gdkhandle.get_origin()
|
||||||
b_width = rect.x - innerx
|
b_width = rect.x - innerx
|
||||||
tb_height = rect.y - innery
|
tb_height = rect.y - innery
|
||||||
#
|
#
|
||||||
# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE)
|
# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE)
|
||||||
# style |= win32con.WS_CLIPCHILDREN
|
# style |= win32con.WS_CLIPCHILDREN
|
||||||
# win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style)
|
# win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style)
|
||||||
# break
|
# break
|
||||||
|
|
||||||
# hud.main_window.set_title(real_name)
|
# hud.main_window.set_title(real_name)
|
||||||
|
|
||||||
def win_enum_handler(hwnd, titles):
|
def win_enum_handler(hwnd, titles):
|
||||||
titles[hwnd] = win32gui.GetWindowText(hwnd)
|
titles[hwnd] = win32gui.GetWindowText(hwnd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user