Wolfteeth Posted March 25, 2011 Share Posted March 25, 2011 (edited) How to Call COM Interface not ObjectBelow is the info from Object Browser while I checkedClass IMessengerConversationWndAdvancedMember of CommunicatorAPIMessenger Conversation Window Advanced InterfaceClass MessengerMember of CommunicatorAPIMessenger Object I know how to create a Object like $oCommunicator = ObjCreate("CommunicatorAPI.Messenger")but how to interactive with the Interface? $R = ObjCreate("CommunicatorAPI.IMessengerConverationWndAdvanced") doesn't work...Actually, if its in VBA code, it just need to declare the data type like Dim r As CommunicatorAPI.IMessengerConversationWndAdvancedbut you know, there's no data type in AutoIT world.see anyone can help? Edited March 25, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
trancexx Posted March 25, 2011 Share Posted March 25, 2011 Object is object and interface is interface. You clearly don't know what either is and relation in between. Get familiar with technical terms, meanings and representations. Then ask questions. Only you wouldn't. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 25, 2011 Share Posted March 25, 2011 You can't instantiate an interface. There's no code. It's just a set of prototypes. Link to comment Share on other sites More sharing options...
Wolfteeth Posted March 26, 2011 Author Share Posted March 26, 2011 (edited) Nono...I dont' fully think so, however, what I really want to know is how to declare the data type? this is what VBA can do: Sub sendMessage() Dim p As CommunicatorAPI.Messenger Dim r As CommunicatorAPI.IMessengerConversationWndAdvanced Dim s As CommunicatorAPI.IMessengerContacts Dim m As CommunicatorAPI.IMessengerContact Dim w As String Dim v As Long Set p = CreateObject("Communicator.UIAutomation") p.AutoSignin Set s = p.MyContacts Set m = p.GetContact("some@dummy.com",CStr(p.MyServiceId)) Set r = p.InstantMessage(m) r.SendText ("hello from VBA Excel. ignore") End Sub but Autoit can only do the part of the above codes as it cannot declare the data type.. $oCommunicator = ObjCreate("Communicator.UIAutomation") $s = $oCommunicator.Mycontacts $m = $oCommunicator.GetContact("soneone@dumy.com", $oCommunicator.MyServiceID) $rr = $oCommunicator.InstantMessage($m) so, see anyone can help? Edited March 28, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
ProgAndy Posted March 26, 2011 Share Posted March 26, 2011 There is a mistake in the VBA-code. rr and r should be the same variable I think. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Wolfteeth Posted March 28, 2011 Author Share Posted March 28, 2011 (edited) There is a mistake in the VBA-code. rr and r should be the same variable I think. Dear, yes, it's typo issue. have corrected. you can tested it in your env, however, please remember to add the reference: Microsoft Office Communicaor 2007 API Type Library reattach again: Sub sendMessage() Dim p As CommunicatorAPI.Messenger Dim r As CommunicatorAPI.IMessengerConversationWndAdvanced Dim s As CommunicatorAPI.IMessengerContacts Dim m As CommunicatorAPI.IMessengerContact Dim w As String Dim v As Long Set p = CreateObject("Communicator.UIAutomation") p.AutoSignin Set s = p.MyContacts Set m = p.GetContact("some@dummy.com",CStr(p.MyServiceId)) Set r = p.InstantMessage(m) r.SendText ("hello from VBA Excel. ignore") End Sub That is what I was confused that then how can I do the same thing in AutoIT... Edited March 28, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
Bowmore Posted March 28, 2011 Share Posted March 28, 2011 (edited) This is untested as I do not have Communicator on my PC. The code below is a direct translation from VB to AutoIt so it should work, Ive added a COM $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler sendMessage() Func sendMessage() Local $p Local $r Local $s Local $m Local $w Local $v $p = ObjCreate("Communicator.UIAutomation") $p.AutoSignin() $s = $p.MyContacts() $m = $p.GetContact("some@dummy.com", $p.MyServiceId) $r = $p.InstantMessage($m) $r.SendTexe("hello from VBA Excel. ignore") EndFunc ;==>sendMessage ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) Endfunc Edit: Fixed tags Edited March 28, 2011 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Wolfteeth Posted March 29, 2011 Author Share Posted March 29, 2011 (edited) @Bowmore,It's not working that displayed the error screen:I think it is still related on the data type issue.We intercepted a COM Error!Number is: 80020006Windescription is: Unknown name. Edited March 29, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
trancexx Posted March 29, 2011 Share Posted March 29, 2011 Change "e" to "t" in last method name. Isn't that obvious? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Wolfteeth Posted March 30, 2011 Author Share Posted March 30, 2011 (edited) Change "e" to "t" in last method name. Isn't that obvious?O. Yes... SendText have been updated, another error is here.We intercepted a COM Error!Number is: 80004001Windescription is: Unknown name. Edited March 30, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
Bowmore Posted March 30, 2011 Share Posted March 30, 2011 Try this. It still wont work but I've changed the error output to give more information about where and why it is failing. $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler sendMessage() Func sendMessage() Local $p Local $r Local $s Local $m Local $w Local $v $p = ObjCreate("Communicator.UIAutomation") $p.AutoSignin() $s = $p.MyContacts() $m = $p.GetContact("some@dummy.com", $p.MyServiceId) $r = $p.InstantMessage($m) $r.SendText("hello from VBA Excel. ignore") EndFunc ;==>sendMessage ; This is my custom error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is" & @TAB & @TAB & ": " & $HexNumber & @CRLF & _ "Windescription is" & @TAB & ": " & $oMyError.windescription & @CRLF & _ "source is" & @TAB & @TAB & ": " & $oMyError.source & @CRLF & _ "description is" & @TAB & ": " & $oMyError.description & @CRLF & _ "helpfile is" & @TAB & @TAB & ": " & $oMyError.helpfile & @CRLF & _ "helpcontext is" & @TAB & ": " & $oMyError.helpcontext & @CRLF & _ "lastdllerror is" & @TAB & ": " & $oMyError.lastdllerror & @CRLF & _ "scriptline is" & @TAB & ": " & $oMyError.scriptline) EndFunc ;==>MyErrFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Wolfteeth Posted March 31, 2011 Author Share Posted March 31, 2011 (edited) @Bowmore, many thanks for your kindly replies and assistance, however, the problem is still exists. I think need to think about the data type. Error: 80004001 Windescription is : Not Implemented source is : description is : helfile is : helpcontext is: lastdllerror is : 0 scriptline is : 19 ($r.SendText("hello from VBA Excel. ignore")) Edited March 31, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
Bowmore Posted March 31, 2011 Share Posted March 31, 2011 At least we now know that the problem is with the SentText line. Having searched MSDN for details of the Communicator Object model it would appear that there is no SendText() method implemented, as per the error message. Where did you get the VBA code from? Did it work? I looks as though you are going to have to use other means of sending you message, for example email or using AutoIt's Send() functions to send text to the messenger GUI. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Wolfteeth Posted April 1, 2011 Author Share Posted April 1, 2011 (edited) MSDN for the API, you can refer to http://msdn.microsoft.com/en-us/library/bb787199(v=office.12).aspx below is using the object browser to get the SendText function and it works. Edited April 20, 2011 by Wolfteeth Link to comment Share on other sites More sharing options...
ProgAndy Posted April 1, 2011 Share Posted April 1, 2011 (edited) I think you'll need to call QueryInterface on the ibject in $r in order to get the advanced-interface. Something like: $oWrapTemp = _AutoItObject_WrapperCreate(_AutoItObject_IDispatchToPtr($r), $dtagIUnknown) $tIID = _AutoItObject_CLSIDFromString("{7C613A61-0633-4c69-AFF0-5BA9F1D28887}") $rAdv = $oWrapTemp.QueryInterface(Number(DLLStructGetPtr($tIID)), 0) $rAdv = _AutoItObject_PtrToIDispatch($rAdv[2]) $oWrapTemp = 0 Edited April 1, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Wolfteeth Posted April 20, 2011 Author Share Posted April 20, 2011 @ProgAndy, sorry, these days are busy on other that have no replies few days.. but its still need to say it is hard for me to understand.. $p = ObjCreate("Communicator.UIAutomation") $p.AutoSignin() $s = $p.MyContacts() $m = $p.GetContact("some@dummy.com", $p.MyServiceId) $r = $p.InstantMessage($m) ; $r.SendText("hello from VBA Excel. ignore") $oWrapTemp = _AutoItObject_WrapperCreate(_AutoItObject_IDispatchToPtr($r), $dtagIUnknown) $tIID = _AutoItObject_CLSIDFromString("{7C613A61-0633-4c69-AFF0-5BA9F1D28887}") $rAdv = $oWrapTemp.QueryInterface(Number(DLLStructGetPtr($tIID)), 0) $rAdv = _AutoItObject_PtrToIDispatch($rAdv[2]) $rAdv.SendText("hello from VBA Excel. ignore") $oWrapTemp = 0 when I run the code, it stops at $rADV = $oWrapTemp.QueryInterface. and the windescription is: "Variable must be of type 'Object'", Number is : 000000A9 I have also searched _AutoITobject_CLSIDfromString, not sure if we can use _CoCreateInstance directly? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now