1
1
import ctypes
2
- import comtypes .automation
3
- import comtypes .typeinfo
4
- import comtypes .client
5
- import comtypes .client .lazybind
6
2
7
- from comtypes import COMError , IUnknown , _is_object
8
- import comtypes .hresult as hres
3
+ from comtypes import automation
4
+ from comtypes .client import lazybind
5
+ from comtypes import COMError , hresult as hres , _is_object
9
6
10
7
# These errors generally mean the property or method exists,
11
8
# but can't be used in this context - eg, property instead of a method, etc.
@@ -24,12 +21,12 @@ def Dispatch(obj):
24
21
# via fully dynamic dispatch
25
22
if isinstance (obj , _Dispatch ):
26
23
return obj
27
- if isinstance (obj , ctypes .POINTER (comtypes . automation .IDispatch )):
24
+ if isinstance (obj , ctypes .POINTER (automation .IDispatch )):
28
25
try :
29
26
tinfo = obj .GetTypeInfo (0 )
30
- except (comtypes . COMError , WindowsError ):
27
+ except (COMError , WindowsError ):
31
28
return _Dispatch (obj )
32
- return comtypes . client . lazybind .Dispatch (obj , tinfo )
29
+ return lazybind .Dispatch (obj , tinfo )
33
30
return obj
34
31
35
32
@@ -45,17 +42,17 @@ def __call__(self, *args):
45
42
46
43
def __getitem__ (self , * args ):
47
44
return self ._obj ._comobj .Invoke (
48
- self ._id , * args , _invkind = comtypes . automation .DISPATCH_PROPERTYGET
45
+ self ._id , * args , _invkind = automation .DISPATCH_PROPERTYGET
49
46
)
50
47
51
48
def __setitem__ (self , * args ):
52
49
if _is_object (args [- 1 ]):
53
50
self ._obj ._comobj .Invoke (
54
- self ._id , * args , _invkind = comtypes . automation .DISPATCH_PROPERTYPUTREF
51
+ self ._id , * args , _invkind = automation .DISPATCH_PROPERTYPUTREF
55
52
)
56
53
else :
57
54
self ._obj ._comobj .Invoke (
58
- self ._id , * args , _invkind = comtypes . automation .DISPATCH_PROPERTYPUT
55
+ self ._id , * args , _invkind = automation .DISPATCH_PROPERTYPUT
59
56
)
60
57
61
58
@@ -70,7 +67,7 @@ def __init__(self, comobj):
70
67
71
68
def __enum (self ):
72
69
e = self ._comobj .Invoke (- 4 ) # DISPID_NEWENUM
73
- return e .QueryInterface (comtypes . automation .IEnumVARIANT )
70
+ return e .QueryInterface (automation .IEnumVARIANT )
74
71
75
72
def __hash__ (self ):
76
73
return hash (self ._comobj )
@@ -118,7 +115,7 @@ def __getattr__(self, name):
118
115
self .__dict__ [name ] = result
119
116
return result
120
117
121
- flags = comtypes . automation .DISPATCH_PROPERTYGET
118
+ flags = automation .DISPATCH_PROPERTYGET
122
119
try :
123
120
result = self ._comobj .Invoke (dispid , _invkind = flags )
124
121
except COMError as err :
@@ -149,8 +146,13 @@ def __iter__(self):
149
146
return _Collection (self .__enum ())
150
147
151
148
# def __setitem__(self, index, value):
152
- # self._comobj.Invoke(-3, index, value,
153
- # _invkind=comtypes.automation.DISPATCH_PROPERTYPUT|comtypes.automation.DISPATCH_PROPERTYPUTREF)
149
+ # self._comobj.Invoke(
150
+ # -3,
151
+ # index,
152
+ # value,
153
+ # _invkind=automation.DISPATCH_PROPERTYPUT
154
+ # | automation.DISPATCH_PROPERTYPUTREF,
155
+ # )
154
156
155
157
156
158
class _Collection (object ):
0 commit comments