@@ -4,6 +4,7 @@ from ctypes import wintypes
44import natlink
55import os
66import rpyc
7+ import struct
78import subprocess
89import sys
910import win32api
@@ -33,13 +34,37 @@ def fix_addin():
3334 # Sometimes Word disables the addin, so it is impossible to
3435 # dictate into Word. This is likely a bug in the addin, but I
3536 # don't have a choice but to work around it.
37+ addin_name = 'Dragon.Word2000Support.1'
3638 with _winreg .OpenKey (_winreg .HKEY_CURRENT_USER ,
3739 r'Software\Microsoft\Office\Word\Addins' ,
3840 0 , _winreg .KEY_ALL_ACCESS ) as addins_key :
3941 try :
40- _winreg .DeleteKey (addins_key , 'Dragon.Word2000Support.1' )
42+ _winreg .DeleteKey (addins_key , addin_name )
43+ logging .info ('Rescued Word addin from being disabled' )
4144 except WindowsError :
4245 pass
46+ # Another location (http://superuser.com/questions/17557/)
47+ with _winreg .OpenKey (_winreg .HKEY_CURRENT_USER ,
48+ r'Software\Microsoft\Office\15.0\Word' +
49+ r'\Resiliency\DisabledItems' ,
50+ 0 , _winreg .KEY_ALL_ACCESS ) as disabled_key :
51+ index = 0
52+ while True :
53+ try :
54+ name , data , rtype = _winreg .EnumValue (disabled_key , index )
55+ format = '3I'
56+ _ , dll_len , name_len = struct .unpack_from (format , buffer (data ))
57+ format += '%ds%ds' % (dll_len , name_len )
58+ _ , _ , _ , dll_path , dll_name = struct .unpack (format , data )
59+ dll_path = dll_path .decode ('utf16' ).rstrip ('\0 ' )
60+ dll_name = dll_name .decode ('utf16' ).rstrip ('\0 ' )
61+ if dll_name .lower () == addin_name .lower ():
62+ _winreg .DeleteValue (disabled_key , name )
63+ logging .info ('Rescued Word addin from Resiliency' )
64+ break
65+ index += 1
66+ except WindowsError :
67+ break
4368
4469def get_document_text (document ):
4570 return document .Content .Text .replace ('\r \n ' , '\n ' ).replace ('\r ' , '\n ' ).rstrip ()
0 commit comments