Improved table-by-name recognition for non-latin window titles
What i mean: u'1464739' in 'Speed #1464739 - \xc1\xcb \xd5\xee\xeb\xe4\xe5\xec' -> Exception u'1464739' in 'Speed #1464739 - \xc1\xcb \xd5\xee\xeb\xe4\xe5\xec'.decode('cp1251') -> True
This commit is contained in:
parent
4074092f32
commit
c042bea181
|
@ -230,11 +230,20 @@ def discover_nt_by_name(c, tablename):
|
|||
"""Finds poker client window with the given table name."""
|
||||
titles = {}
|
||||
win32gui.EnumWindows(win_enum_handler, titles)
|
||||
|
||||
def getDefaultEncoding():
|
||||
# FIXME: if somebody know better place fot this function - move it
|
||||
# FIXME: it's better to use GetCPInfo for windows http://msdn.microsoft.com/en-us/library/dd318078(VS.85).aspx
|
||||
# but i have no idea, how to call it
|
||||
import locale
|
||||
return locale.getpreferredencoding()
|
||||
|
||||
for hwnd in titles:
|
||||
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
||||
try:
|
||||
# maybe it's better to make global titles[hwnd] decoding?
|
||||
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
||||
if not tablename.lower() in titles[hwnd].lower(): continue
|
||||
if not tablename.lower() in titles[hwnd].decode(getDefaultEncoding()).lower(): continue
|
||||
except:
|
||||
continue
|
||||
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
||||
|
|
Loading…
Reference in New Issue
Block a user