From niks9731 at gmail.com Wed Apr 6 19:57:52 2016 From: niks9731 at gmail.com (Nikhil L) Date: Thu, 7 Apr 2016 05:27:52 +0530 Subject: [python-win32] Handle pywin32 installation after a custom pywin32 installation Message-ID: Hello All, I am working on creating an installer which installs pywin32 silently on the target VM. I am able to achieve that with Mark's suggestion at https://sourceforge.net/p/pywin32/feature-requests/86/. My concern though is that the user of the target VM should be able to install the original pywin32 installer (by original I mean the one wherein he/she can go through the UI to install pywin32) if he/she chooses since I can't really place any restriction on the user. So, if the user does install pywin32 after my custom pywin32 the installation is successful but when the user uninstalls the pywin32, it deletes all the files and folders that my custompywin32 uses. To workaround that, I installed the custom pywin32 at a different location (didn't copy the supporting files to site-packages but to other location) and modified my scripts to use the custom location. I also had to manually copy the pywintypes27.dll and place it under win32 directory under my custom location to make it work. But after doing this, when I install pywin32, the installation completes but at the final page it says below things: "Close failed in file object destructor Error in sys.excepthook Original exception was:" Any tips on how to avoid this or any suggestions as to what I might be doing wrong? Let me know if you need more clarification on the question or on the description of my question. Thanks, Nikhil -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukaszj at onet.pl Sat Apr 9 17:57:16 2016 From: lukaszj at onet.pl (=?iso-8859-2?B?o3VrYXN6IEpha3Vib3dza2k=?=) Date: Sat, 09 Apr 2016 23:57:16 +0200 Subject: [python-win32] Potential problem with calling Invoke Message-ID: Hello, Please look up the following forum post: http://resource.dopus.com/viewtopic.php?f=12&t=24125&p=136297&hilit=python#p136297 Is this really some indication of a pywin32 problem? Please mind that the provided example call should be really: comm = DOpus.Create().Command().CommandList('u') but using () does not work (a version without parentheses needs to be used or _FlagAsMethod). CommandList accepts 0 or more arguments, while Create and Command accept 0 arguments. It seems using () should result in proper calling of a COM object? Regards, Lukasz From timr at probo.com Mon Apr 11 13:20:01 2016 From: timr at probo.com (Tim Roberts) Date: Mon, 11 Apr 2016 10:20:01 -0700 Subject: [python-win32] Potential problem with calling Invoke In-Reply-To: References: Message-ID: <570BDCC1.7080107@probo.com> ?ukasz Jakubowski wrote: > Please look up the following forum post: > http://resource.dopus.com/viewtopic.php?f=12&t=24125&p=136297&hilit=python#p136297 > > Is this really some indication of a pywin32 problem? > > Please mind that the provided example call should be really: > comm = DOpus.Create().Command().CommandList('u') > but using () does not work (a version without parentheses needs to be used > or _FlagAsMethod). > CommandList accepts 0 or more arguments, while Create and Command accept 0 > arguments. > > It seems using () should result in proper calling of a COM object? This is really an ugly situation. They are wrong to say that this is "100% a bug in Python". It's partly their fault as well. The problem is that the IDispatch mechanism is ambiguous, and they have designed their object model in a way that absolutely invites misinterpretation. Their CommandList object supports calls with no parameters, it supports calls with one parameter, and it supports a default dispatch. By being overly accommodating, technically speaking, their object has publicly advertised that it supports Python's interpretation (fetching a property result and calling its default dispatch), and there is no way for them to say they prefer one over the other. Python happens to prefer the default dispatch solution when given a choice, and this is the result. At the core, this decision is made in CDispatch.__call__ in win32com\client\dynamic, but that's so fundamental to IDispatch operation that I don't know the implications of changing the order. In the short term, I suspect you could work around this in an ugly way: cmd = DOpus.Create().Command() cmd._olerepr_.defaultDispatchName = None comm = cmd.CommandList('u') -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From shawn.geller at nist.gov Mon Apr 11 13:25:09 2016 From: shawn.geller at nist.gov (Geller, Shawn (Assoc)) Date: Mon, 11 Apr 2016 17:25:09 +0000 Subject: [python-win32] Setting the value of an array of clusters in LabVIEW from python Message-ID: Hi there. I've been able to use the COM client to set the value of a cluster, and I've been able to set the value of an array, both using the "setcontrolvalue" method, but I've been unable to set the value of an array of clusters. How do I do this? Here's some example code: import win32com.client output_vi = LabVIEW.GetVIReference("C:\\Geller\\LabVIEW_code\\output.vi") output_vi.setcontrolvalue('Cluster', (1,2.0,2.0)) # This is able to set the value of a cluster output_vi.setcontrolvalue('Array',(1,1,2,3,5,8,13,21)) # This is able to set the value of an array output_vi.setcontrolvalue('Array of Cluster',((1,1.0,1.2),(3,2.0,2.2))) # But this fails Can you help me out here? Thanks, Shawn -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn.geller at nist.gov Mon Apr 11 13:59:44 2016 From: shawn.geller at nist.gov (Geller, Shawn (Assoc)) Date: Mon, 11 Apr 2016 17:59:44 +0000 Subject: [python-win32] Setting the value of an array of clusters in LabVIEW from python In-Reply-To: References: , Message-ID: *I get an empty array on the front panel of my VI. ________________________________ From: Geller, Shawn (Assoc) Sent: Monday, April 11, 2016 11:59 AM To: python-win32 at python.org Subject: Re: Setting the value of an array of clusters in LabVIEW from python P.S. In fact, even if I do: cv = output_vi.getcontrolvalue('Array of Cluster') after manually putting something into the array of clusters, and immediately saying output_vi.setcontrolvalue('Array of Cluster', cv) I get an empty cluster on the front panel of my VI. ________________________________ From: Geller, Shawn (Assoc) Sent: Monday, April 11, 2016 11:25 AM To: python-win32 at python.org Subject: Setting the value of an array of clusters in LabVIEW from python Hi there. I've been able to use the COM client to set the value of a cluster, and I've been able to set the value of an array, both using the "setcontrolvalue" method, but I've been unable to set the value of an array of clusters. How do I do this? Here's some example code: import win32com.client output_vi = LabVIEW.GetVIReference("C:\\Geller\\LabVIEW_code\\output.vi") output_vi.setcontrolvalue('Cluster', (1,2.0,2.0)) # This is able to set the value of a cluster output_vi.setcontrolvalue('Array',(1,1,2,3,5,8,13,21)) # This is able to set the value of an array output_vi.setcontrolvalue('Array of Cluster',((1,1.0,1.2),(3,2.0,2.2))) # But this fails Can you help me out here? Thanks, Shawn -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn.geller at nist.gov Mon Apr 11 13:59:14 2016 From: shawn.geller at nist.gov (Geller, Shawn (Assoc)) Date: Mon, 11 Apr 2016 17:59:14 +0000 Subject: [python-win32] Setting the value of an array of clusters in LabVIEW from python In-Reply-To: References: Message-ID: P.S. In fact, even if I do: cv = output_vi.getcontrolvalue('Array of Cluster') after manually putting something into the array of clusters, and immediately saying output_vi.setcontrolvalue('Array of Cluster', cv) I get an empty cluster on the front panel of my VI. ________________________________ From: Geller, Shawn (Assoc) Sent: Monday, April 11, 2016 11:25 AM To: python-win32 at python.org Subject: Setting the value of an array of clusters in LabVIEW from python Hi there. I've been able to use the COM client to set the value of a cluster, and I've been able to set the value of an array, both using the "setcontrolvalue" method, but I've been unable to set the value of an array of clusters. How do I do this? Here's some example code: import win32com.client output_vi = LabVIEW.GetVIReference("C:\\Geller\\LabVIEW_code\\output.vi") output_vi.setcontrolvalue('Cluster', (1,2.0,2.0)) # This is able to set the value of a cluster output_vi.setcontrolvalue('Array',(1,1,2,3,5,8,13,21)) # This is able to set the value of an array output_vi.setcontrolvalue('Array of Cluster',((1,1.0,1.2),(3,2.0,2.2))) # But this fails Can you help me out here? Thanks, Shawn -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukaszj at onet.pl Tue Apr 12 17:21:52 2016 From: lukaszj at onet.pl (=?iso-8859-2?B?o3VrYXN6IEpha3Vib3dza2k=?=) Date: Tue, 12 Apr 2016 23:21:52 +0200 Subject: [python-win32] Potential problem with calling Invoke In-Reply-To: <570BDCC1.7080107@probo.com> References: <570BDCC1.7080107@probo.com> Message-ID: Hi Tim, Thanks for taking a look. Do you have maybe some quick idea for some way of fixing it with intermediate code, so that fe. calls are verified for result and reissued in another style/_FlaggedAsMethod and reissued - and _FlagAsMethod or using cmd._olerepr_.defaultDispatchNam later in code is not required? I imagine that it could work as some extra import, and then would allow using all the Directory Opus API without any special provisions. I don't want to mess with pywin32 code. Looks like great python exercise :) Regards, Lukasz Dnia Mon, 11 Apr 2016 19:20:01 +0200, Tim Roberts napisa?: > ?ukasz Jakubowski wrote: >> Please look up the following forum post: >> http://resource.dopus.com/viewtopic.php?f=12&t=24125&p=136297&hilit=python#p136297 >> >> Is this really some indication of a pywin32 problem? >> >> Please mind that the provided example call should be really: >> comm = DOpus.Create().Command().CommandList('u') >> but using () does not work (a version without parentheses needs to be >> used >> or _FlagAsMethod). >> CommandList accepts 0 or more arguments, while Create and Command >> accept 0 >> arguments. >> >> It seems using () should result in proper calling of a COM object? > > This is really an ugly situation. > > They are wrong to say that this is "100% a bug in Python". It's partly > their fault as well. The problem is that the IDispatch mechanism is > ambiguous, and they have designed their object model in a way that > absolutely invites misinterpretation. Their CommandList object supports > calls with no parameters, it supports calls with one parameter, and it > supports a default dispatch. By being overly accommodating, technically > speaking, their object has publicly advertised that it supports Python's > interpretation (fetching a property result and calling its default > dispatch), and there is no way for them to say they prefer one over the > other. Python happens to prefer the default dispatch solution when > given a choice, and this is the result. > > At the core, this decision is made in CDispatch.__call__ in > win32com\client\dynamic, but that's so fundamental to IDispatch > operation that I don't know the implications of changing the order. In > the short term, I suspect you could work around this in an ugly way: > > cmd = DOpus.Create().Command() > cmd._olerepr_.defaultDispatchName = None > comm = cmd.CommandList('u') > -- U?ywam klienta poczty Opera Mail: http://www.opera.com/mail/ From timr at probo.com Wed Apr 13 13:30:29 2016 From: timr at probo.com (Tim Roberts) Date: Wed, 13 Apr 2016 10:30:29 -0700 Subject: [python-win32] Potential problem with calling Invoke In-Reply-To: References: <570BDCC1.7080107@probo.com> Message-ID: <570E8235.7020904@probo.com> ?ukasz Jakubowski wrote: > Do you have maybe some quick idea for some way of fixing it with > intermediate code, so that fe. calls are verified for result and reissued > in another style/_FlaggedAsMethod and reissued - and _FlagAsMethod or > using cmd._olerepr_.defaultDispatchNam later in code is not required? Do you mean totally general case? I don't think there is a general case solution, because there's no general case way to decide which interpretation is correct. My suggested hack-around works for your specific case, and it may be that's the best you can do. I'd love to have Mark Hammond take a whack at this. He's really the PythonCom expert. > I imagine that it could work as some extra import, and then would allow > using all the Directory Opus API without any special provisions. I don't > want to mess with pywin32 code. I don't think you should be afraid to mess with the pywin32 code. One of the huge benefits of Python is that you HAVE the library source code. You can save away the original and make changes -- with enough debug prints to swamp a large boat -- and if your experiments don't help, go back to the original, no harm done. And if they DO help, well now you have something to contribute to the community. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From breamoreboy at yahoo.co.uk Sat Apr 16 16:56:37 2016 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 16 Apr 2016 21:56:37 +0100 Subject: [python-win32] Python in Visual Studio Message-ID: For anybody who might be interested this is a podcast featuring Steve Dower from Microsoft https://talkpython.fm/episodes/show/53/python-in-visual-studio -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tritium-list at sdamon.com Sat Apr 16 20:22:32 2016 From: tritium-list at sdamon.com (Alexander Walters) Date: Sat, 16 Apr 2016 20:22:32 -0400 Subject: [python-win32] Python in Visual Studio In-Reply-To: References: Message-ID: <5712D748.2020505@sdamon.com> As a total aside, PTVS (part of the base VS 2015 install, IIRC) is now my editor of choice when editing python on windows, edging out gvim (...primarily because you can make vim bindings work in VS). It is a really good editor, with really good code completion features... which makes sense, considering how much money microsoft spent on intelisense. On 4/16/2016 16:56, Mark Lawrence via python-win32 wrote: > For anybody who might be interested this is a podcast featuring Steve > Dower from Microsoft > https://talkpython.fm/episodes/show/53/python-in-visual-studio > From zturner at google.com Sat Apr 16 22:08:05 2016 From: zturner at google.com (Zachary Turner) Date: Sun, 17 Apr 2016 02:08:05 +0000 Subject: [python-win32] Python in Visual Studio In-Reply-To: <5712D748.2020505@sdamon.com> References: <5712D748.2020505@sdamon.com> Message-ID: The debugger is good too. I don't know of any other tool that lets you seamlessly step between Python and native code when debugging a program which embeds Python On Sat, Apr 16, 2016 at 5:23 PM Alexander Walters wrote: > As a total aside, PTVS (part of the base VS 2015 install, IIRC) is now > my editor of choice when editing python on windows, edging out gvim > (...primarily because you can make vim bindings work in VS). It is a > really good editor, with really good code completion features... which > makes sense, considering how much money microsoft spent on intelisense. > > On 4/16/2016 16:56, Mark Lawrence via python-win32 wrote: > > For anybody who might be interested this is a podcast featuring Steve > > Dower from Microsoft > > https://talkpython.fm/episodes/show/53/python-in-visual-studio > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sean.true at gmail.com Sun Apr 17 13:42:10 2016 From: sean.true at gmail.com (Sean True) Date: Sun, 17 Apr 2016 13:42:10 -0400 Subject: [python-win32] Unsubscribe Message-ID: Unsubscribe On Sunday, April 17, 2016, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denes1951 at yahoo.ca Mon Apr 18 21:26:01 2016 From: denes1951 at yahoo.ca (Denes L) Date: Tue, 19 Apr 2016 01:26:01 +0000 (UTC) Subject: [python-win32] COM events References: <1626024362.2436468.1461029161041.JavaMail.yahoo.ref@mail.yahoo.com> Message-ID: <1626024362.2436468.1461029161041.JavaMail.yahoo@mail.yahoo.com> Hi I am having trouble figuring out how do add events to a COM UI interface. So far all the things that I have tried after reading posts on many forums either result in an error, cause the interface to hang or do nothing at all. The UI in reference is the SAP Business One UI API Version 9.0 a.k.a. SAbouiCOM.exe The documentation has examples in VB and C# which I have copied below in case they help. I am not familiar with Windows programming, VB, or C# by any strectch of one's imagination so at this stage any help is appreciated and it will be promptly tried out. First some relevant parts from the makepy output, and when I say relevant it is what I imagine to be important, I can post the whole thing somewhere if required: # -*- coding: mbcs -*- # Created by makepy.py version 0.5.01 # By python version 2.7.11 (v2.7.11:6d1b6a68f775, Dec? 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] # From type library 'SAPbouiCOM.exe' # On Sun Mar 06 18:20:27 2016 class _IApplicationEvents: ??? '_IApplicationEvents Interface' ??? CLSID = CLSID_Sink = IID('{81B441CB-BB83-44B2-8A62-6DFBEB7B6217}') ??? coclass_clsid = IID('{49B5C554-9A6B-4530-A90D-2B51B27BCEDA}') ??? _public_methods_ = [] # For COM Server support ??? _dispid_to_func_ = { ??? ??? ????? 120 : "OnLayoutKeyEvent", ??? ??? ????? 103 : "OnStatusBarEvent", ??? ??? ????? 100 : "OnItemEvent", ??? ??? ????? 109 : "OnWidgetEvent", ??? ??? ????? 108 : "OnFormDataEvent", ??? ??? ????? 106 : "OnReportDataEvent", ??? ??? ????? 101 : "OnMenuEvent", ??? ??? ????? 202 : "OnServerInvokeCompletedEvent", ??? ??? ????? 201 : "OnUDOEvent", ??? ??? ????? 102 : "OnAppEvent", ??? ??? ????? 104 : "OnProgressBarEvent", ??? ??? ????? 105 : "OnPrintEvent", ??? ??? ????? 107 : "OnRightClickEvent", ??? ??? } ??? def __init__(self, oobj = None): ??? ??? if oobj is None: ??? ??? ??? self._olecp = None ??? ??? else: ??? ??? ??? import win32com.server.util ??? ??? ??? from win32com.server.policy import EventHandlerPolicy ??? ??? ??? cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) ??? ??? ??? cp=cpc.FindConnectionPoint(self.CLSID_Sink) ??? ??? ??? cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) ??? ??? ??? self._olecp,self._olecp_cookie = cp,cookie ??? def __del__(self): ??? ??? try: ??? ??? ??? self.close() ??? ??? except pythoncom.com_error: ??? ??? ??? pass ??? def close(self): ??? ??? if self._olecp is not None: ??? ??? ??? cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None ??? ??? ??? cp.Unadvise(cookie) ??? def _query_interface_(self, iid): ??? ??? import win32com.server.util ??? ??? if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) ??? # Event Handlers ??? # If you create handlers, they should have the following prototypes: #??? def OnLayoutKeyEvent(self, eventInfo=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method LayoutKeyEvent' #??? def OnStatusBarEvent(self, Text=defaultNamedNotOptArg, messageType=defaultNamedNotOptArg): #??? ??? 'method StatusBarEvent' #??? def OnItemEvent(self, FormUID=defaultNamedNotOptArg, pVal=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'ItemEvent' #??? def OnWidgetEvent(self, pWidgetData=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method WidgetEvent' #??? def OnFormDataEvent(self, BusinessObjectInfo=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method FormDataEvent' #??? def OnReportDataEvent(self, eventInfo=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method ReportDataEvent' #??? def OnMenuEvent(self, pVal=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'MenuEvent' #??? def OnServerInvokeCompletedEvent(self, b1iEventArgs=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method ServerInvokeCompletedEvent' #??? def OnUDOEvent(self, udoEventArgs=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method UDOEvent' #??? def OnAppEvent(self, EventType=defaultNamedNotOptArg): #??? ??? 'ApplicationEvent' #??? def OnProgressBarEvent(self, pVal=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method ProgressBarEvent' #??? def OnPrintEvent(self, eventInfo=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method PrintEvent' #??? def OnRightClickEvent(self, eventInfo=defaultNamedNotOptArg, BubbleEvent=pythoncom.Missing): #??? ??? 'method RightClickEvent' # This CoClass is known by the name 'SAPbouiCOM.Application.90.0' class Application(CoClassBaseClass): # A CoClass ??? # Application Class ??? CLSID = IID('{49B5C554-9A6B-4530-A90D-2B51B27BCEDA}') ??? coclass_sources = [ ??? ??? _IApplicationEvents, ??? ] ??? default_source = _IApplicationEvents ??? coclass_interfaces = [ ??? ??? IApplication, ??? ] ??? default_interface = IApplication class IApplication(DispatchBaseClass): ??? 'IApplication Interface' ??? CLSID = IID('{D1F75D47-137C-4335-AC2A-3FE209831B6A}') ??? coclass_clsid = IID('{49B5C554-9A6B-4530-A90D-2B51B27BCEDA}') ??? def ActivateMenuItem(self, MenuUID=defaultNamedNotOptArg): ??? ??? 'method ActivateMeunItem' ??? ??? return self._oleobj_.InvokeTypes(52, LCID, 1, (24, 0), ((8, 1),),MenuUID ??? ??? ??? ) ??? def ActivateToolbar(self, MenuUID=defaultNamedNotOptArg): ??? ??? 'method ActivateToolbar' ??? ??? return self._oleobj_.InvokeTypes(86, LCID, 1, (24, 0), ((8, 1),),MenuUID ??? ??? ??? ) ??? def CreateObject(self, Type=defaultNamedNotOptArg): ??? ??? 'Method CreateObject' ??? ??? ret = self._oleobj_.InvokeTypes(65, LCID, 1, (9, 0), ((3, 1),),Type ??? ??? ??? ) ??? ??? if ret is not None: ??? ??? ??? ret = Dispatch(ret, u'CreateObject', None) ??? ??? return ret ??? def ExportRptAsXML(self, rptPath=defaultNamedNotOptArg, params=defaultNamedNotOptArg): ??? ??? 'property ExportRptAsXML' ??? ??? # Result is a Unicode object ??? ??? return self._oleobj_.InvokeTypes(75, LCID, 1, (8, 0), ((8, 1), (8, 1)),rptPath ??? ??? ??? , params) ??? # Result is of type IEventFilters ??? def GetFilter(self): ??? ??? 'GetFilter' ??? ??? ret = self._oleobj_.InvokeTypes(56, LCID, 1, (9, 0), (),) ??? ??? if ret is not None: ??? ??? ??? ret = Dispatch(ret, u'GetFilter', '{CE8A5ED3-BA2B-4CE1-932A-53F4E92994F0}') ??? ??? return ret ??? def GetFormItemDefaultHeight(self, itemType=defaultNamedNotOptArg): ??? ??? 'GetFormItemDefaultHeight' ??? ??? return self._oleobj_.InvokeTypes(81, LCID, 1, (3, 0), ((3, 1),),itemType ??? ??? ??? ) ??? def GetFormItemDefaultWidth(self, itemType=defaultNamedNotOptArg): ??? ??? 'GetFormItemDefaultWidth' ??? ??? return self._oleobj_.InvokeTypes(80, LCID, 1, (3, 0), ((3, 1),),itemType ??? ??? ??? ) ??? def GetLastBatchResults(self): ??? ??? 'GetLastBatchResults' ??? ??? # Result is a Unicode object ??? ??? return self._oleobj_.InvokeTypes(57, LCID, 1, (8, 0), (),) ??? def LoadBatchActions(self, XmlStr=defaultNamedNotOptArg): ??? ??? 'Batch Action' ??? ??? return self._ApplyTypes_(54, 1, (24, 0), ((16392, 3),), u'LoadBatchActions', None,XmlStr ??? ??? ??? ) ??? def MessageBox(self, Text=defaultNamedNotOptArg, DefaultBtn=1, Btn1Caption=u'Ok', Btn2Caption=u'' ??? ??? ??? , Btn3Caption=u''): ??? ??? 'method MessageBox' ??? ??? return self._ApplyTypes_(50, 1, (3, 32), ((8, 1), (3, 49), (8, 49), (8, 49), (8, 49)), u'MessageBox', None,Text ??? ??? ??? , DefaultBtn, Btn1Caption, Btn2Caption, Btn3Caption) ??? # Result is of type IForm ??? def OpenForm(self, sysObjectType=defaultNamedNotOptArg, bstrUDOObjectType=defaultNamedNotOptArg, bstrObjectKey=defaultNamedNotOptArg): ??? ??? 'method OpenForm' ??? ??? ret = self._oleobj_.InvokeTypes(84, LCID, 1, (9, 0), ((3, 1), (8, 1), (8, 1)),sysObjectType ??? ??? ??? , bstrUDOObjectType, bstrObjectKey) ??? ??? if ret is not None: ??? ??? ??? ret = Dispatch(ret, u'OpenForm', '{50BA08F8-4392-4395-B35A-50C93CA91A0C}') ??? ??? return ret ??? def RemoveWindowsMessage(self, messageType=defaultNamedNotOptArg, toProcess=defaultNamedNotOptArg): ??? ??? 'method RemoveWindowsMessage' ??? ??? return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((3, 1), (11, 1)),messageType ??? ??? ??? , toProcess) ??? def SendKeys(self, Text=defaultNamedNotOptArg): ??? ??? 'method SendKeys' ??? ??? return self._oleobj_.InvokeTypes(53, LCID, 1, (24, 0), ((8, 1),),Text ??? ??? ??? ) ??? def Serialize(self, inXML=defaultNamedNotOptArg): ??? ??? ' Serialize' ??? ??? # Result is a Unicode object ??? ??? return self._oleobj_.InvokeTypes(85, LCID, 1, (8, 0), ((8, 1),),inXML ??? ??? ??? ) ??? def ServerInvoke(self, RequestUri=defaultNamedNotOptArg): ??? ??? 'method ServerInvoke' ??? ??? # Result is a Unicode object ??? ??? return self._oleobj_.InvokeTypes(100, LCID, 1, (8, 0), ((8, 1),),RequestUri ??? ??? ??? ) ??? def SetFilter(self, Filter=0): ??? ??? 'SetFilter' ??? ??? return self._oleobj_.InvokeTypes(55, LCID, 1, (24, 0), ((9, 49),),Filter ??? ??? ??? ) ??? def SetStatusBarMessage(self, Text=defaultNamedNotOptArg, Seconds=20, IsError=True): ??? ??? 'method SetStatusBarMessage' ??? ??? return self._oleobj_.InvokeTypes(51, LCID, 1, (24, 0), ((8, 1), (3, 49), (11, 49)),Text ??? ??? ??? , Seconds, IsError) ??? _prop_map_get_ = { ??? ??? "AppId": (20, 2, (3, 0), (), "AppId", None), ??? ??? # Method 'Cockpits' returns object of type 'ICockpits' ??? ??? "Cockpits": (70, 2, (9, 0), (), "Cockpits", '{49193AF4-562F-4E9A-82C6-9B79B6C66383}'), ??? ??? # Method 'Company' returns object of type 'ICompany' ??? ??? "Company": (11, 2, (9, 0), (), "Company", '{195BCB8E-4D2F-4950-947C-9E3523929229}'), ??? ??? # Method 'Desktop' returns object of type 'IDesktop' ??? ??? "Desktop": (10, 2, (9, 0), (), "Desktop", '{F88352F1-5027-41CF-861B-3D7FE6D40CCD}'), ??? ??? "EventLevel": (110, 2, (3, 0), (), "EventLevel", None), ??? ??? "FocusRestored": (106, 2, (11, 0), (), "FocusRestored", None), ??? ??? "FontHeight": (83, 2, (3, 0), (), "FontHeight", None), ??? ??? "FontName": (82, 2, (8, 0), (), "FontName", None), ??? ??? # Method 'Forms' returns object of type 'IForms' ??? ??? "Forms": (1, 2, (9, 0), (), "Forms", '{02B99871-8ACD-446E-A24F-7645E7DF4B70}'), ??? ??? "IsHostedEnvironment": (107, 2, (11, 0), (), "IsHostedEnvironment", None), ??? ??? "Language": (21, 2, (3, 0), (), "Language", None), ??? ??? # Method 'Menus' returns object of type 'IMenus' ??? ??? "Menus": (2, 2, (9, 0), (), "Menus", '{BD3E79E3-F688-47D6-9030-5714F3079FA0}'), ??? ??? "MetadataAutoRefresh": (66, 2, (11, 0), (), "MetadataAutoRefresh", None), ??? ??? # Method 'ResourceData' returns object of type 'IResourceData' ??? ??? "ResourceData": (67, 2, (9, 0), (), "ResourceData", '{3C771B45-1C75-4AE7-B88E-D2D102D445BE}'), ??? ??? "SkinStyle": (68, 2, (3, 0), (), "SkinStyle", None), ??? ??? # Method 'StatusBar' returns object of type 'IStatusBar' ??? ??? "StatusBar": (64, 2, (9, 0), (), "StatusBar", '{C1DC17AD-B039-4E27-87C2-84F7EC82313F}'), ??? ??? "XSEngineBaseURL": (111, 2, (8, 0), (), "XSEngineBaseURL", None), ??? } ??? _prop_map_put_ = { ??? ??? "EventLevel": ((110, LCID, 4, 0),()), ??? ??? "FocusRestored": ((106, LCID, 4, 0),()), ??? ??? "MetadataAutoRefresh": ((66, LCID, 4, 0),()), ??? } ??? def __iter__(self): ??? ??? "Return a Python iterator for this object" ??? ??? try: ??? ??? ??? ob = self._oleobj_.InvokeTypes(-4,LCID,3,(13, 10),()) ??? ??? except pythoncom.error: ??? ??? ??? raise TypeError("This object does not support enumeration") ??? ??? return win32com.client.util.Iterator(ob, None) # This CoClass is known by the name 'SAPbouiCOM.SboGuiApi.90.0' class SboGuiApi(CoClassBaseClass): # A CoClass ??? # SboGuiApi Class ??? CLSID = IID('{6CF0D1E0-470B-4684-B9B5-70F9A5ACBB06}') ??? coclass_sources = [ ??? ] ??? coclass_interfaces = [ ??? ??? ISboGuiApi, ??? ] ??? default_interface = ISboGuiApi To get the UI going: from win32com.client import Dispatch ui = Dispatch("SAPbouiCOM.SboGuiApi") ui.AddonIdentifier = "..." conn = ui.Connect("...") app = ui.GetApplication() # functions like create msg boxes, windows, grids, etc. work fine A sample program in C#: // **************************************************************************** //? BEFORE STARTING: //? 1. Add reference to the "SAP Business One UI API" //? 2. Insert the development connection string to the "Command line argument" // ----------------------------------------------------------------- //? 1. //???? a. Project->Add Reference... //???? b. select the "SAP Business One UI API 2007" From the COM folder // //? 2. //????? a. Project->Properties... //????? b. choose Configuration Properties folder (place the arrow on Debugging) //????? c. place the connection string in the 'Command line arguments' field // // ************************************************************************************************** using Microsoft.VisualBasic; using System; namespace FilterEvents { ??? public class EventFilter? { ??????? private SAPbouiCOM.Application SBO_Application; ??????? //********************************************************** ??????? // declaring an Event filters container object and an ??????? // event filter object ??????? //********************************************************** ??????? public SAPbouiCOM.EventFilters oFilters; ??????? public SAPbouiCOM.EventFilter oFilter; ??????? private void SetApplication() { ??????????? // ******************************************************************* ??????????? // Use an SboGuiApi object to establish connection ??????????? // with the SAP Business One application and return an ??????????? // initialized appliction object ??????????? // ******************************************************************* ??????????? SAPbouiCOM.SboGuiApi SboGuiApi = null; ??????????? string sConnectionString = null; ??????????? SboGuiApi = new SAPbouiCOM.SboGuiApi(); ??????????? // by following the steped specified above the following ??????????? // statment should be suficient for either development or run mode ??????????? sConnectionString = Interaction.Command(); ??????????? // connect to a running SBO Application ??????????? SboGuiApi.Connect( sConnectionString ); ??????????? // get an initialized application object ??????????? SBO_Application = SboGuiApi.GetApplication( -1 ); ??????? } ??????? private void SetFilters() { ??????????? // Create a new EventFilters object ??????????? oFilters = new SAPbouiCOM.EventFilters(); ??????????? // add an event type to the container ??????????? // this method returns an EventFilter object ??????????? oFilter = oFilters.Add( SAPbouiCOM.BoEventTypes.et_CLICK ); ??????????? // assign the form type on which the event would be processed ??????????? oFilter.AddEx( "139" ); // Orders Form ??????????? oFilter.AddEx( "142" ); // Purchase Form ??????????? oFilter = oFilters.Add( SAPbouiCOM.BoEventTypes.et_KEY_DOWN ); ??????????? // assign the form type on which the event would be processed ??????????? oFilter.Add( 139 ); // Orders Form ??????????? // For a list of all form types see the help or use the ??????????? // Tools -> User Tools -> Display Debug Information option ??????????? // in the SBO application ??????????? // then open the desired form and hover over it with the mouse ??????????? // the form's type will apear in the lower left side of the screen ??????????? // Setting the application with the EventFilters object ??????????? // in this case we will process a click event for form types 142 and 139 ??????????? // and we will process a key down event for for form type 139 ??????????? SBO_Application.SetFilter( oFilters ); ??????? } ??????? public EventFilter() { ??????????? //************************************************************* ??????????? // set SBO_Application with an initialized application object ??????????? //************************************************************* ??????????? SetApplication(); ??????????? //************************************************************* ??????????? // set SBO_Application with an initialized EventFilters object ??????????? //************************************************************* ??????????? SetFilters(); ??????????? // events handled by SBO_Application_AppEvent ??????????? SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler( SBO_Application_AppEvent ); ??????????? // events handled by SBO_Application_MenuEvent ??????????? SBO_Application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler( SBO_Application_MenuEvent ); ??????????? // events handled by SBO_Application_ItemEvent ??????????? SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler( SBO_Application_ItemEvent ); ??????? } ??????? private void SBO_Application_AppEvent( SAPbouiCOM.BoAppEventTypes EventType ) { ??????????? //******************************************************************************** ??????????? // the following are the events sent by the application ??????????? // (Ignore aet_ServerTermination) ??????????? // in order to implement your own code upon each of the events ??????????? // place you code instead of the matching message box statement ??????????? //******************************************************************************** ??????????? switch ( EventType ) { ??????????????? case SAPbouiCOM.BoAppEventTypes.aet_ShutDown: ??????????????????? SBO_Application.MessageBox( "A Shut Down Event has been caught" + Constants.vbNewLine + "Terminating Add On...", 1, "Ok", "", "" ); ??????????????????? //************************************************************** ??????????????????? // ??????????????????? // Take care of terminating your AddOn application ??????????????????? // ??????????????????? //************************************************************** ??????????????????? System.Environment.Exit( 0 ); ??????????????????? break; ??????????????? case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged: ??????????????????? SBO_Application.MessageBox( "A Company Change Event has been caught", 1, "Ok", "", "" ); ??????????????????? //************************************************************** ??????????????????? // Check the new company name, if your add on was not meant for ??????????????????? // the new company terminate your AddOn ??????????????????? //??? If SBO_Application.Company.Name Is Not "Company1" then ??????????????????? //???????? Close ??????????????????? //??? End If ??????????????????? //************************************************************** ??????????????????? break; ??????????????? case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged: ??????????????????? SBO_Application.MessageBox( "A Languge Change Event has been caught", 1, "Ok", "", "" ); ??????????????????? //************************************************************** ??????????????????? // Check the new language name, if your AddOn's items needs ??????????????????? // to be changed, take care of it at this point ??????????????????? // ??????????????????? //??? Select Case SBO_Application.Language ??????????????????? //???????? Case ln_English: ??????????????????? //???????? Case ln_French: ??????????????????? //???????? Case ln_German: ??????????????????? //??? End Select ??????????????????? //************************************************************** ??????????????????? break; ??????????? } ??????? } ??????? private void SBO_Application_MenuEvent( ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent ) { ??????????? BubbleEvent = true; ??????????? //******************************************************************************** ??????????? // in order to activate your own forms instead of SAP Business One system forms ??????????? // process the menu event by your self ??????????? // change BubbleEvent to True so that SAP Business One won't process it ??????????? //******************************************************************************** ??????????? if ( pVal.BeforeAction == true ) { ??????????????? SBO_Application.SetStatusBarMessage( "Menu item: " + pVal.MenuUID + " sent an event BEFORE SAP Business One processes it.", SAPbouiCOM.BoMessageTime.bmt_Long, true ); ??????????????? // to stop SAP Business One from processing this event ??????????????? // unmark the following statement ??????????????? // BubbleEvent = True ??????????? } ??????????? else { ??????????????? SBO_Application.SetStatusBarMessage( "Menu item: " + pVal.MenuUID + " sent an event AFTER SAP Business One processes it.", SAPbouiCOM.BoMessageTime.bmt_Long, true ); ??????????? } ??????? } ??????? private void SBO_Application_ItemEvent( string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent ) { ??????????? BubbleEvent = true; ??????????? //************************************************************************** ??????????? // BubbleEvent sets the behavior of SAP Business One. ??????????? // False means that the application will not continue processing this event ??????????? // True is the default value ??????????? //************************************************************************** ??????????? if ( pVal.FormType != 0 & pVal.Before_Action == true ) { ??????????????? //************************************************************ ??????????????? // the message box form type is 0 ??????????????? // I chose not to deal with events triggered by a message box ??????????????? //************************************************************ ??????????????? switch ( pVal.EventType ) { ??????????????????? case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED: ??????????????????????? // Specifies a button release (After exit). ??????????????????????? SBO_Application.MessageBox( "An et_ITEM_PRESSED has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_KEY_DOWN: ??????????????????????? // Specifies a key down event. ??????????????????????? SBO_Application.MessageBox( "An et_KEY_DOWN has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_GOT_FOCUS: ??????????????????????? // Specifies an item got focus. ??????????????????????? SBO_Application.MessageBox( "An et_GOT_FOCUS has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS: ??????????????????????? // Specifies an item lost focus. ??????????????????????? SBO_Application.MessageBox( "An et_LOST_FOCUS has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT: ??????????????????????? // Specifies the selection of valid value in Combo Box. ??????????????????????? SBO_Application.MessageBox( "An et_COMBO_SELECT has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_CLICK: ??????????????????????? // Specifies Mouse Up on editable item. ??????????????????????? SBO_Application.MessageBox( "An et_CLICK has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK: ??????????????????????? // Specifies Mouse Up on editable item in time interval define by ??????????????????????? // SAP Business One as double-click. ??????????????????????? SBO_Application.MessageBox( "An et_DOUBLE_CLICK has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_MATRIX_LINK_PRESSED: ??????????????????????? // Specifies a link arrow within a matrix was pressed. ??????????????????????? SBO_Application.MessageBox( "An et_MATRIX_LINK_PRESSED has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_MATRIX_COLLAPSE_PRESSED: ??????????????????????? // Specifies collapsed or expanded list within a matrix. ??????????????????????? SBO_Application.MessageBox( "An et_MATRIX_COLLAPSE_PRESSED has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_VALIDATE: ??????????????????????? //Specifies an item validation event. ??????????????????????? SBO_Application.MessageBox( "An et_VALIDATE has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_LOAD: ??????????????????????? // Specifies that SAP Business One application opened a form. ??????????????????????? SBO_Application.MessageBox( "An et_FORM_LOAD has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD: ??????????????????????? // Specifies that SAP Business One application closed a form. ??????????????????????? SBO_Application.MessageBox( "An et_FORM_UNLOAD has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE: ??????????????????????? // Specifies that the focus is set on the form. ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_DEACTIVATE: ??????????????????????? // Specifies that the form lost focus. ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE: ??????????????????????? // Specifies that the form was closed by calling the Close event. ??????????????????????? SBO_Application.MessageBox( "An et_FORM_CLOSE has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_RESIZE: ??????????????????????? // Specifies resizing of the form. ??????????????????????? SBO_Application.MessageBox( "An et_FORM_RESIZE has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????????? case SAPbouiCOM.BoEventTypes.et_FORM_KEY_DOWN: ??????????????????????? // Specifies a key press on an area which is not item of the form. ??????????????????????? SBO_Application.MessageBox( "An et_FORM_KEY_DOWN has been sent by a form with the unique ID: " + FormUID, 1, "Ok", "", "" ); ??????????????????????? break; ??????????????? } ??????????? } ??????? } ??? } } And the same sample program in Visual Basic: '**************************************************************************** ' BEFORE STARTING: ' 1. Add reference to the "SAP Business One UI API" ' 2. Insert the development connection string to the "Command line argument" '----------------------------------------------------------------- ' 1. '??? a. Project->Add Reference... '??? b. select the "SAP Business One UI API 2007" From the COM folder ' ' 2. '???? a. Project->Properties... '???? b. choose Configuration Properties folder (place the arrow on Debugging) '???? c. place the connection string in the 'Command line arguments' field ' '************************************************************************************************** Option Strict Off Option Explicit On Public Class EventFilter ??? Private WithEvents SBO_Application As SAPbouiCOM.Application ??? '//********************************************************** ??? '// declaring an Event filters container object and an ??? '// event filter object ??? '//********************************************************** ??? Public oFilters As SAPbouiCOM.EventFilters ??? Public oFilter As SAPbouiCOM.EventFilter ??? Private Sub SetApplication() ??????? '******************************************************************* ??????? '// Use an SboGuiApi object to establish connection ??????? '// with the SAP Business One application and return an ??????? '// initialized appliction object ??????? '******************************************************************* ??????? Dim SboGuiApi As SAPbouiCOM.SboGuiApi ??????? Dim sConnectionString As String ??????? SboGuiApi = New SAPbouiCOM.SboGuiApi() ??????? '// by following the steped specified above the following ??????? '// statment should be suficient for either development or run mode ??????? sConnectionString = Command() ??????? '// connect to a running SBO Application ??????? SboGuiApi.Connect(sConnectionString) ??????? '// get an initialized application object ??????? SBO_Application = SboGuiApi.GetApplication() ??? End Sub ??? Private Sub SetFilters() ??????? '// Create a new EventFilters object ??????? oFilters = New SAPbouiCOM.EventFilters() ??????? '// add an event type to the container ??????? '// this method returns an EventFilter object ??????? oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_CLICK) ??????? '// assign the form type on which the event would be processed ??????? oFilter.AddEx("139") 'Orders Form ??????? oFilter.AddEx("142") 'Purchase Form ??????? oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_KEY_DOWN) ??????? '// assign the form type on which the event would be processed ??????? oFilter.Add(139) 'Orders Form ??????? '// For a list of all form types see the help or use the ??????? '// Tools -> User Tools -> Display Debug Information option ??????? '// in the SBO application ??????? '// then open the desired form and hover over it with the mouse ??????? '// the form's type will apear in the lower left side of the screen ??????? '// Setting the application with the EventFilters object ??????? '// in this case we will process a click event for form types 142 and 139 ??????? '// and we will process a key down event for for form type 139 ??????? SBO_Application.SetFilter(oFilters) ??? End Sub ??? Public Sub New() ??????? '//************************************************************* ??????? '// set SBO_Application with an initialized application object ??????? '//************************************************************* ??????? SetApplication() ??????? '//************************************************************* ??????? '// set SBO_Application with an initialized EventFilters object ??????? '//************************************************************* ??????? SetFilters() ??? End Sub ??? Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent ??????? '//******************************************************************************** ??????? '// the following are the events sent by the application ??????? '// (Ignore aet_ServerTermination) ??????? '// in order to implement your own code upon each of the events ??????? '// place you code instead of the matching message box statement ??????? '//******************************************************************************** ??????? Select Case EventType ??????????? Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown ??????????????? SBO_Application.MessageBox("A Shut Down Event has been caught" _ ??????????????????? & vbNewLine & "Terminating Add On...") ??????????????? '//************************************************************** ??????????????? '// ??????????????? '// Take care of terminating your AddOn application ??????????????? '// ??????????????? '//************************************************************** ??????????????? End ??????????? Case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged ??????????????? SBO_Application.MessageBox("A Company Change Event has been caught") ??????????????? '//************************************************************** ??????????????? '// Check the new company name, if your add on was not meant for ??????????????? '// the new company terminate your AddOn ??????????????? '//??? If SBO_Application.Company.Name Is Not "Company1" then ??????????????? '//???????? Close ??????????????? '//??? End If ??????????????? '//************************************************************** ??????????? Case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged ??????????????? SBO_Application.MessageBox("A Languge Change Event has been caught") ??????????????? '//************************************************************** ??????????????? '// Check the new language name, if your AddOn's items needs ??????????????? '// to be changed, take care of it at this point ??????????????? '// ??????????????? '//??? Select Case SBO_Application.Language ??????????????? '//???????? Case ln_English: ??????????????? '//???????? Case ln_French: ??????????????? '//???????? Case ln_German: ??????????????? '//??? End Select ??????????????? '//************************************************************** ??????? End Select ??? End Sub ??? Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent ??????? '//******************************************************************************** ??????? '// in order to activate your own forms instead of SAP Business One system forms ??????? '// process the menu event by your self ??????? '// change BubbleEvent to True so that SAP Business One won't process it ??????? '//******************************************************************************** ??????? If pVal.beforeAction = True Then ??????????? SBO_Application.SetStatusBarMessage( _ ??????????? "Menu item: " + pVal.menuUID + " sent an event BEFORE SAP Business One processes it.", SAPbouiCOM.BoMessageTime.bmt_Long, True) ??????????? '// to stop SAP Business One from processing this event ??????????? '// unmark the following statement ??????????? '// BubbleEvent = True ??????? Else ??????????? SBO_Application.SetStatusBarMessage( _ ??????????? "Menu item: " & pVal.menuUID & " sent an event AFTER SAP Business One processes it.", SAPbouiCOM.BoMessageTime.bmt_Long, True) ??????? End If ??? End Sub ??? Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent ??????? '//************************************************************************** ??????? '// BubbleEvent sets the behavior of SAP Business One. ??????? '// False means that the application will not continue processing this event ??????? '// True is the default value ??????? '//************************************************************************** ??????? If pVal.formType <> 0 And pVal.Before_Action = True Then ??????????? '//************************************************************ ??????????? '// the message box form type is 0 ??????????? '// I chose not to deal with events triggered by a message box ??????????? '//************************************************************ ??????????? Select Case pVal.EventType ??????????????? '//************************************************************ ??????????????? '// every event will open a message box with the event ??????????????? '// name and the form UID how sent it ??????????????? '//************************************************************ ??????????? Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED ??????????????????? '// Specifies a button release (After exit). ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_ITEM_PRESSED has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN ??????????????????? '// Specifies a key down event. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_KEY_DOWN has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_GOT_FOCUS ??????????????????? '// Specifies an item got focus. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_GOT_FOCUS has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS ??????????????????? '// Specifies an item lost focus. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_LOST_FOCUS has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT ??????????????????? '// Specifies the selection of valid value in Combo Box. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_COMBO_SELECT has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_CLICK ??????????????????? '// Specifies Mouse Up on editable item. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_CLICK has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK ??????????????????? '// Specifies Mouse Up on editable item in time interval define by ??????????????????? '// SAP Business One as double-click. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_DOUBLE_CLICK has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_MATRIX_LINK_PRESSED ??????????????????? '// Specifies a link arrow within a matrix was pressed. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_MATRIX_LINK_PRESSED has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_MATRIX_COLLAPSE_PRESSED ??????????????????? '// Specifies collapsed or expanded list within a matrix. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_MATRIX_COLLAPSE_PRESSED has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_VALIDATE ??????????????????? '//Specifies an item validation event. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_VALIDATE has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD ??????????????????? '// Specifies that SAP Business One application opened a form. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_FORM_LOAD has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD ??????????????????? '// Specifies that SAP Business One application closed a form. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_FORM_UNLOAD has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE ??????????????????? '// Specifies that the focus is set on the form. ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_DEACTIVATE ??????????????????? '// Specifies that the form lost focus. ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE ??????????????????? '// Specifies that the form was closed by calling the Close event. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_FORM_CLOSE has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_RESIZE ??????????????????? '// Specifies resizing of the form. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_FORM_RESIZE has been sent by a form with the unique ID: " + FormUID) ??????????????? Case SAPbouiCOM.BoEventTypes.et_FORM_KEY_DOWN ??????????????????? '// Specifies a key press on an area which is not item of the form. ??????????????????? SBO_Application.MessageBox( _ ??????????????????? "An et_FORM_KEY_DOWN has been sent by a form with the unique ID: " + FormUID) ??????????? End Select ??????? End If ??? End Sub End Class Thanks, Denes -------------- next part -------------- An HTML attachment was scrubbed... URL: From Colin.Blair at GDIT.com Fri Apr 22 10:47:46 2016 From: Colin.Blair at GDIT.com (Blair, Colin S) Date: Fri, 22 Apr 2016 14:47:46 +0000 Subject: [python-win32] pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) In-Reply-To: References: Message-ID: <1461336465606.3079@GDIT.com> Hi Tim, I have figured out the source of this error. We are running into issues with the comObjectModelGaurd. Our group policy recently changed to disallow programatic access to protected mailItem objects. Modifying Outlook Users Trust settings or the registry will fix the problem. R, C. Blair ________________________________________ From: Blair, Colin S Sent: Wednesday, March 9, 2016 7:33 AM To: python-win32 at python.org Subject: pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) Thank for the response. I have tried using the static proxy. The same error occurs. I have also tried adding DISP_E_EXCEPTION to the ERRORS_BAD_CONTEXT list in dynamic.py Same result. R, Colin B. Blair, Colin S wrote: > Please assist me with this error: > > Traceback (most recent call last): > > print msg.Body > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in > __getattr__ > return self._ApplyTypes_(*args) > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in > _ApplyTypes_self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), > pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) That's 0x80004005, which for MAPI is MAPI_E_CALL_FAILED. Very generic. Have you run gentypes.py on Outlook? Perhaps you should try to generate a static proxy: ol = win32com.client.gencache.EnsureDispatch("Outlook.Application") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.