Hi Thank you!
BTW, why 'dte' is not implicitly available in Visual Studio console? I found in some old (2006-2008) docs that 'dte' preexists in the console. On Sun, Jun 26, 2011 at 7:06 PM, Steve Dower <s.j.do...@gmail.com> wrote: > The MSDN docs show the difference between the two: > > http://msdn.microsoft.com/en-us/library/envdte.events.solutionevents.aspx > http://msdn.microsoft.com/en-us/library/envdte.events.outputwindowevents.aspx > > In short, OutputWindowEvents takes an (optional) parameter. You don't > see this in C# because it doesn't support parameterised properties, > but neither does Python (though you can fake it with __getitem__). If > you 'call' the property (or is that call the 'property'?) it will get > the value: > > EnvDTE._dispOutputWindowEvents_Event.add_PaneUpdated(dte.Events.OutputWindowEvents(), > onupdated) > > The other thing to keen in mind with EnvDTE events is that you have to > keep the event objects alive or you will stop receiving notifications, > so you will at least need to do: > > Events_OutputWindowEvents = dte.Events.OutputWindowEvents() > EnvDTE._dispOutputWindowEvents_Event.add_PaneUpdated(Events_OutputWindowEvents, > onupdated) > > and make sure that Events_OutputWindowEvents doesn't get collected. > > On Sun, Jun 26, 2011 at 04:23, Denis <de...@camfex.cz> wrote: >> Hi >> I am trying to automating some boring task by writing macros for >> Visual Studio 2010. >> I am not a .NET nor C# expert, I work with C++ and have some Python >> background. >> So Python seemed more comfortable for me to do the task. >> >> What I got stuck on is receiving Visual Studio events. >> Some of them can be handled well but other are not. >> By irony, the latters events are the ones that needed to be handled. >> >> Ok, let us start from IronPython console in Visual Studio 2010. >> >> >>>> import clr >>>> clr.AddReference("EnvDTE") >>>> import EnvDTE, System.Runtime.InteropServices.Marshal >>>> dte = >>>> System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE") >> >>>> def onopen(): print 'solution opened!' >>>> EnvDTE._dispSolutionEvents_Event.add_Opened(dte.Events.SolutionEvents, >>>> onopen) >> >> >> Ok, the event installed and even works fine. >> Lets go on. >> >> >>>> def onupdated(): print 'pane updated!' >>>> EnvDTE._dispOutputWindowEvents_Event.add_PaneUpdated(dte.Events.OutputWindowEvents, >>>> onupdated) >> Traceback (most recent call last): >> File "<string>", line 1, in <module> >> TypeError: expected _dispOutputWindowEvents_Event, got DispCallable >> >>>» print type(dte.Events.OutputWindowEvents) >> <type 'DispCallable'> >> >>>» print type(dte.Events.SolutionEvents) >> <type '__ComObject'> >> >> >> Oops. >> Seems like dte.Events.SolutionEvents and dte.Events.OutputWindowEvents >> are not similar at all. >> Why do they have so different type? >> Both events works similar way with VisualBasic. >> >> Thinking that DispCallable may have something todo with IDispatch, >> lets try another way: >> >> >>> dte.Events.OutputWindowEvents("add_PaneUpdated", onupdated) >> Traceback (most recent call last): >> File "<string>", line 1, in <module> >> StandardError: Error while invoking OutputWindowEvents. >> >> >> Oops again :( >> So how to deal with DispCallable? >> How to query interface _dispOutputWindowEvents_Event on it? >> >> Thanks in advance. >> _______________________________________________ >> Ironpython-users mailing list >> Ironpython-users@python.org >> http://mail.python.org/mailman/listinfo/ironpython-users >> > _______________________________________________ Ironpython-users mailing list Ironpython-users@python.org http://mail.python.org/mailman/listinfo/ironpython-users