JRowe Posted April 1, 2009 Share Posted April 1, 2009 (edited) I'm pretty sure it's simple. I'm trying to get an activex control working. The ocx is registered, the object creation is passing with flying colors. I want to convert this to AutoIt. Dim obj Sub Object1_Click() Dim ask As String Dim answer As String Dim i As Integer If IsEmpty(obj) Then Set obj = CreateObject("AIML.AIMLCtrl.1") obj.SetAIMLFile "c:\AIMLpad\myaimlset.aiml" obj.SetOptionsFile "c:\AIMLpad\options.ini" ask = InputBox("Ask") While ask <> "" answer = obj.Talk(ask) ask = InputBox(answer) Wend End Sub This is what I have: Global $g_eventerror = 0; to be checked to know if com error occurs. Must be reset after handling. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler $brain = ObjCreate("AIML.AIMLCtrl.1") MsgBox(0,"","loaded control") $brain.SetAIMLFile("c:\AIMLocx\myaimlset.aiml") MsgBox(0,"","loaded aiml") $brain.SetOptionsFile("c:\AIMLocx\options.ini") $ask = "Ask" MsgBox(0,"Test" , $brain.Talk($ask)) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $g_eventerror = 1; something to check for when this function returns Endfunc I have a vague idea that I should be using objEvent , but I've been trying various combinations and don't quite get it yet. There are only 3 functions I'm trying to use: Talk(STRING) , SetAIMLFile(STRING) , and SetOptionsFile(STRING). Talk() is the only one that returns anything. You send text, it returns a response. How do I use objEvent to access the Talk method, assuming that's what I should be doing? I am currently getting the "catastrophic failure" error. Thanks! Edited April 1, 2009 by JRowe [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
JRowe Posted April 1, 2009 Author Share Posted April 1, 2009 Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler $brain = ObjCreate("AIML.AIMLCtrl.1") MsgBox(0,"","loaded control") ObjEvent($brain, "AIML_") MsgBox(0,"","loaded control") $brain.SetAIMLFile("c:\AIMLocx\myaimlset.aiml") MsgBox(0,"","loaded aiml") $brain.SetOptionsFile("c:\AIMLocx\options.ini") AIML_Talk("Test") Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $g_eventerror = 1; something to check for when this function returns Endfunc Func AIML_Talk($Ask) MsgBox(0,"blah", $brain.Talk($Ask)) EndFuncI have a feeling I'm getting closer, but I can't find any clear examples, and the COM reference isn't quite dumb enough for me. The only example I can find that is similar to what I want to do is progandy's mammoth SAPI script: http://www.autoitscript.com/forum/index.php?showtopic=70079[ uuid(66AB77FE-DB2E-4F24-A659-FD0C272BA81E), helpstring("Dispatch interface for AIML Control") ] dispinterface _DAIML { properties: [id(0xfffffdf3) ] long ReadyState; methods: [id(0x00000001)] BSTR Talk(BSTR Ask); [id(0x00000002)] BSTR Reply(BSTR Tmplt); [id(0x00000003)] void SetReadyState(BSTR sState); [id(0x00000004)] void SetAimlFile(BSTR sName); [id(0x00000005)] void SetOptionsFile(BSTR sName); [id(0x00000006)] BSTR GetSecond(); [id(0x00000007)] void SetSecond(BSTR sName); [id(0xfffffdd8)] void AboutBox(); };Thought maybe that might help. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
JRowe Posted April 1, 2009 Author Share Posted April 1, 2009 http://216.128.99.72/AIMLpad/ is the program I'm trying to work with.http://216.128.99.72/AIMLpad/AIMLocx.ziphttp://216.128.99.72/AIMLpad/AIMLocx_Source.zipThat's the ActiveX control and source. This is about as good as chatbots get. It's got everything from OpenCyc to ConceptNet, with a built in expert system and scripting language. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 1, 2009 Share Posted April 1, 2009 I don't understand the side road you took with events, etc. Did the original VBS you posted work? That just translates to something like this: Global $obj Object1_Click() Func Object1_Click() Local $ask Local $answer If Not IsObj($obj) Then $obj = ObjCreate("AIML.AIMLCtrl.1") $obj.SetAIMLFile("c:\AIMLpad\myaimlset.aiml") $obj.SetOptionsFile("c:\AIMLpad\options.ini") $ask = InputBox("Ask", "Enter 'Ask' text: ") While $ask <> "" $answer = $obj.Talk($ask) $ask = InputBox("Answer = " & $answer, "Enter 'Ask' text: ") Wend EndFunc I can't test because I don't have the object loaded, because I don't download stuff from raw IP addresses, and because I have no interest in chat bots. You'll have to go to the documentation for the object you got. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JRowe Posted April 1, 2009 Author Share Posted April 1, 2009 http://www.google.com/search?hl=en&q=a...mp;aq=f&oq= Dunno why, but that guys homepage has been that way for almost a decade. Never got around to buying a domain name, I guess. it's the AIMLPad page, first link returned by google. Still getting catastrophic failure (8000FFFF) on any method call. I took the turn into objEvent() sort of randomly, because the SAPI example I found seemed closest in structure to what I was trying to do. Anyway, here's the re-write with com error handler: Global $obj $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler Object1_Click() Func Object1_Click() Local $ask Local $answer If Not IsObj($obj) Then $obj = ObjCreate("AIML.AIMLCtrl.1") $obj.SetAIMLFile("c:\AIMLpad\myaimlset.aiml") $obj.SetOptionsFile("c:\AIMLpad\options.ini") $ask = InputBox("Ask", "Enter 'Ask' text: ") While $ask <> "" $answer = $obj.Talk($ask) $ask = InputBox("Answer = " & $answer, "Enter 'Ask' text: ") Wend EndFunc Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $g_eventerror = 1; something to check for when this function returns Endfunc I used regview to verify that AIML.ocx is indeed registered and present where expected. OLEview shows the methods and properties clearly, and according to everything I've read in the Com reference, the simple rewrite should work. I tried reregistering and end up in the same boat. Could this be an OS issue? The docs include the sample code, some AIML specific stuff unrelated to installing or using the activex control, and this: The class of the control is "AIML.AIMLCtrl.1". The control has one method the returns a string called Talk(string ask), for example: "reply = objAIML.Talk(ask)". [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
Authenticity Posted April 1, 2009 Share Posted April 1, 2009 JRowe,Did the original VBS you posted work? Link to comment Share on other sites More sharing options...
JRowe Posted April 1, 2009 Author Share Posted April 1, 2009 Yes, according to the author, it works. I dont have VB installed to check (which might well be a good idea.) I'll do that and see if it works. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
Authenticity Posted April 1, 2009 Share Posted April 1, 2009 Nope, it doesn't work I've tested it on JScript, VBScript, AutoIt and always got Catastrophic Error 0x8000FFFF. Lemme check it with Visual Basic. Link to comment Share on other sites More sharing options...
JRowe Posted April 1, 2009 Author Share Posted April 1, 2009 Well, damn. I guess I'll have to take it apart and try to fix what's broken. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
ptrex Posted April 2, 2009 Share Posted April 2, 2009 (edited) @JRowe First of all the code you showed is not VBS but VB, so there is no 1 to 1 translations to AU3. This is how it should look when translated to AU3 expandcollapse popup; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Object1_Click() Func Object1_Click() Local $obj Local $ask Local $answer Local $i $obj = ObjCreate("AIML.AIMLCtrl.1") $obj.SetAIMLFile ("c:\AIMLpad\myaimlset.aiml") $obj.SetOptionsFile ("c:\AIMLpad\options.ini") $ask = InputBox("Input", "Ask") While $ask <> "" $answer = $obj.Talk($ask) $ask = InputBox("Input", $answer) Wend EndFunc Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc If there is an error coming up then there might be something wrong on your machine where the COM object is not registered correctly. Regards, ptrex Edited April 2, 2009 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
JRowe Posted April 2, 2009 Author Share Posted April 2, 2009 (edited) Thank you Upon further reading, I noted that the example script is meant as an excel macro. How do i go about correctly registering a control? Is there a tool or method i can use to track errors or guide me to a correct configuration? ***** Also, it doesnt work at all as a macro. Looks like its a case of it working on the authors system but nowhere else- I've tried it on 4 different machines, various versions of XP. None4me , qq. I will have to grab the source and make things work. Edited April 2, 2009 by JRowe [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
JRowe Posted April 5, 2009 Author Share Posted April 5, 2009 Ok, recompiled, and I'm getting the same errors. How can I figure out what's broken, or debug what's going on when the catastrophic failures occur? [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] 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