talwyn has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to useWin32::OLE to communicate with an ActiveX control that is part of my company's software for testing purposes.

Win32::OLE->new( $classid,\&quit) works and I can directly drive the object's methods and retrieve events. Problem is I don't want to redevelop the controlling application for this, so I tried Win32::OLE->GetActiveObject().

Win32::OLE->GetActiveObject($classid) however fails to return a reference to the control. I have the application that uses the control running but trying to get a reference returns undef and Win32::OLE->LastError() returns 0.

My objective was to listen in to event triggers to verify control activity. Am I missing something or is there a better approach to accomplishing this sort of hook?

Replies are listed 'Best First'.
Re: Win32::OLE Question
by Anonymous Monk on Nov 12, 2008 at 11:14 UTC
    The documentation says:
    The GetActiveObject() class method returns an OLE reference to a running instance of the specified OLE automation server. It returns undef if the server is not currently active. It will croak if the class is not even registered. The optional DESTRUCTOR method takes either a method name or a code reference. It is executed when the last reference to this object goes away. It is generally considered impolite to stop applications that you did not start yourself.
    So you have to activate your server, usually by *win32 ole automation server programming details here*