Jump to content
Sign in to follow this  
jchd

Problem using COM events

Recommended Posts

jchd

I'm experiencing an unexpected "No such interface" error (error 80004002) while trying to use any event described in the Eudora COM interface (see my previous post for docs and wrapper).

Here's an sketch of the offending code:

$oApp = ObjCreate($_EudoraApp) ; works fine, no problem here
        If IsObj($oApp) Then
            Local $oNewMail = ObjEvent($oApp, "Eudora_", "OnCheckMailComplete") ; error 80004002
if IsObj($oNewMail) Then ConsoleWrite("check event created" & @LF)
            Local $oSendMail = ObjEvent($oApp, "Eudora_", "OnSendMailComplete") ; error 80004002
if IsObj($oSendMail) Then ConsoleWrite("send event created" & @LF)
            Local $oClose = ObjEvent($oApp, "Eudora_", "OnClose") ; error 80004002
if IsObj($oClose) Then ConsoleWrite("close event created" & @LF)
    EndIf


Func Eudora_OnClose()
    ConsoleWrite("closing" & @LF)
EndFunc

Func Eudora_OnCheckMailComplete()
    ConsoleWrite("checking done" & @LF)
EndFunc

Func Eudora_OnSendMailComplete()
    ConsoleWrite("sending done" & @LF)
EndFunc

Func MyErrFunc()
 $ErrNumber = Hex($oMyError.number, 8)
ConsoleWrite("COM error " & $ErrNumber & ' ' & $oMyError.windescription & @LF) ; get here each time when registering event functions
Endfunc

I've checked there are no spelling error in the event names in the docs (see post) and that the event names are well present identically in Eudora.exe

I know the COM support works for Eudora objects, properties and methods, no problem. Only events are an issue and of course I badly need them working.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
jchd

Bingo, that surprises me but it works this way: every new invokation of ObjEvent($oApp, "Eudora_") finds the next event function in turn. Hence I get:

check event created

send event created

close event created

Kudos and warm thanks Authenticity!

I wonder how multiple invokations of the same unparametrized function magically discovers the next AutoIt function using the right prefix in turn. I understand it works the other way round: AutoIt provides the next "unassigned" function having the right prefix. Perhaps would it be worth to provide the hint in the helpfile page, as it isn't obvious (at least to me) how such black art works. That behavior is possibly due to the fact that the Eudora COM server was modelled on a more or less primitive version of OLE2 (the server is part of the .EXE) but the trick could solve similar issues to other users having the same problem with other programs.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
MvGulik

jchd.

What happens if you use @CR instead of @CRLF. (just curious.)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
jchd

@MvGulik,

ConsoleWrite("abc" & @CR)
ConsoleWrite("def" & @LF)
ConsoleWrite("ghi" & @CRLF)

produces identical results:

abc

def

ghi

+>06:56:14 AutoIT3.exe ended.rc:0

Now the bad news is that the event declared first (id = 1) in the typelib (Generated .IDL file by the OLE/COM Object Viewer) is the only one which gets ever invoked.

The declarations look like this:

[

uuid(EDA00000-AAAA-11D0-B3C5-00805F8AA4FB),

version(1.0),

helpstring("Eudora Type Library")

]

library EudoraLib

{

// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}

importlib("StdOle2.Tlb");

// Forward declare all types defined in this typelib

dispinterface IEuApplicationEvents;

interface IEuApplication;

interface IEuFolders;

interface IEuFolder;

interface IEuMessages;

interface IEuMessage;

[

uuid(EDA30001-AAAA-11D0-B3C5-00805F8AA4FB),

helpstring("IEuApplication Events")

]

dispinterface IEuApplicationEvents {

properties:

methods:

[id(0x00000001)]

HRESULT OnClose();

[id(0x00000002), helpstring("method OnFolderChange")]

HRESULT OnFolderChange();

[id(0x00000003), helpstring("method OnCheckMailComplete")]

HRESULT OnCheckMailComplete();

[id(0x00000004), helpstring("method OnSendMailComplete")]

HRESULT OnSendMailComplete();

[id(0x00000005), helpstring("method OnEmptyTrashComplete")]

HRESULT OnEmptyTrashComplete();

[id(0x00000006), helpstring("method OnCompactFoldersComplete")]

HRESULT OnCompactFoldersComplete();

};

[

uuid(EDA20001-AAAA-11D0-B3C5-00805F8AA4FB),

helpstring("EuApplication Class")

]

...

Does anyone have an idea about how to link functions to methods other than 1? By name doesn't work, as the first post shows. Is there another way to specify the target event method, even if this needs a ugly kludge? Maybe a registry tweak could work but I really don't know enough there to guess anything.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Authenticity

Can you post the related code?

Share this post


Link to post
Share on other sites
MvGulik

@MvGulik,

ConsoleWrite("abc" & @CR)
ConsoleWrite("def" & @LF)
ConsoleWrite("ghi" & @CRLF)

produces identical results:

abc

def

ghi

+>06:56:14 AutoIT3.exe ended.rc:0

Right. I focused on the wrong differances in Authenticity code and yours. :blink:

Or, I overlooked the ObjEvent($oApp, "Eudora_") part.


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
wraithdu

@jchd

You should not be calling ObjEvent more than once. Calling it once will 'register' all your functions. So do as Authenticity showed in post #2.

If that doesn't work, try

ObjEvent($oApp, "Eudora_", "IEuApplicationEvents")

In either case, make sure you assign ObjEvent to a global variable. If it is not assigned or the variable goes out of scope, you will stop receiving events.

Share this post


Link to post
Share on other sites
jchd

Thanks to all who answered with advices but nothing seems to work correctly. Only the first even declared in the tlb ever activates (it's the OnClose event) whatever approach I use (one global [named or not] ObjEvent or multiple ObjEvent with named methods [prefix or not, causes "no such interface"]).

Worst, even if the OnClose event fires and execute the corresponding routine the Eudora executable gets hung and disappears from the task bar. It then needs to be explicitely killed by Process Explorer, which may lead to data loss.

All in all, the COM server doesn't seem to be compatible with the environment or has inherent problems. I also tried to force compatibility with W98 with sucess.

I really had a need for that to work but I'm going to give up.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.