And this in order to organize UDF's in a better way, and get the benifit of using METHODS, PROPERTIES and EVENTS.
Well actualy there is an ancient technique that supports this.
For those who are not familiar with the technique it is called :
Windows Script Components
More information can be found here :Windows® Script Components provide you with an easy way to create powerful, reusable COM components in script. You create script components using any scripting language that supports the Microsoft® ActiveX® Scripting interfaces. Script languages that support these interfaces include JScript, Microsoft® Visual Basic® Scripting Edition (VBScript), PERLScript, PScript, and Python.
COM Support
This new script component technology supports common types of COM components, such as Automation, and is extensible with add-ons such as DHTML behaviors.
Script Components:
Are small and efficient.
Are easy to create, maintain, and deploy.
Provide the ability to create COM components.
Provide access to a broad range of system services.
Using script components, you can create COM components for a variety of tasks, such as performing middle-tier business logic, accessing and manipulating database data, adding transaction processing to applications, and adding interactive effects to a Web page using DHTML Behaviors.
Writing COM Objects with Scripting Languages
Windows Script Components: They Get Around
OK enough talking :
The files *.WSC and *.SCT are VBScript that use XML to create Fully compliant COM objects.
(Search on your PC and propably you will find some .WSC files.)
RightClick the Files and you can select REGISTER / UNREGISTER and GENERATE TYPE LIB is used for the Windows InTelliSence popups.
These Example scripts explain EXPOSING COM Objects TO AU3 :
Save this as a file called DEMO.SCT
<scriptlet> <Registration Description="DemoScriptlet" ProgID="Demo.Scriptlet" Version="1.00" ClassID="{3ac6e5c0-9f18-11d1-83d1-f49604c10000}" > </Registration> <implements id=Automation type=Automation> <method name=Method1> <PARAMETER name=param1/> </method> <property name="Property1" internalname="mProp1"> </property> </implements> <script language=JScript> var mProp1 = ""; function Method1(param1) { return "Method1(param1)"; } </script> </scriptlet>
Right click the Demo.sct file and select REGISTER. If you don't have a context menu to register it. you will need to do it manually,
using the REGSVR32 command.
; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objWSC = ObjCreate("Demo.Scriptlet") $MethodWSC_0 = $objWSC.Method1 = 0 $MethodWSC_1 = $objWSC.Method1 = 1 Msgbox(0,"Your Own COM object TEST", $MethodWSC_0) Msgbox(0,"Your Own COM object TEST", $MethodWSC_1) 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 EndfuncoÝ÷ Ù8b²+d{¦¦W¡×ºÑÊ&¦ÞÞ¶ëJÞ+-«b¢zk¢oÝ÷ Ù» 릦W¬r¸©¶Ç±¦V¢EÏ9" #9¸ÞrÛ¢Z+ QtÓM,¥©ì·)^oÝ÷ ÚäáDZjjezÈhÂËazÇ+_WjÇ{¦¦W¿¹&¯zØb±ø¥y«*º@St®*mëh«b¢t®÷«ÂÇ*ºZ×hm~àzÛhè"²×«Ý÷ßz®¢×¥µÊ&¦ÞØ-ÚÞ+-«b¢zk¢oÝ÷ Ù*"Ýz»hrZ,zØ^r*Üë¬zØb²Ç+m¡Æ¥*.ˬ¶8Êç-~º&T®*mI«ÞÖ¬ªê-MºËhæãyËSzËonÊ®¢Ö§v»§×(uåÊ&{8Ô[§rبg¥rãN5)²¡zYCg&u'¡¸ÖHoÝ÷ Ù:ò¶!jx¶§¶)íz·¬¶éz¸¨u©Ý±ç° «aj^Æ®¶sc²æFƦR4ôÒW'&÷"æFÆW"¢b33c¶ô×W'&÷"Òö&¤WfVçBgV÷C´WFôBäW'&÷"gV÷C²ÂgV÷C´×W'$gVæ2gV÷C²¢b33c¶ö&¥u42Òö&¤7&VFRgV÷C´S$4ôÕôfææ6Âåu42gV÷C² ¤b4ö&¢b33c¶ö&¥u42FVà¢b33c´ÆöâÒb33c¶ö&¥u42äÆöäÖ÷'F¦FöâÃ2Ã#B²&æ6ÆRÖ÷VçBÂçFW&W7BÂW&ö@ ¤×6t&÷ÂgV÷C´6ÆÆ&6²S$4ôÒgV÷C²ÂgV÷Cµ÷W"Ö÷'F¦FöâW"ÖöçF2¢gV÷C²fײ5"fײb33c¶ö&¥u42äÖ÷'F¦FöâfײgV÷C²b33c²ògV÷C²²&W7VÇB&WGW&æVBg&öÒS$4ôÐ ¤VÇ6R ×6t&÷ÂgV÷C´W'&÷"gV÷C²ÂgV÷C´æòvööBö&¦V7BFV6Æ&VBgV÷C²¤VæD` ¤gVæ2×W'$gVæ2¢b33c´WçVÖ&W#ÖWb33c¶ô×W'&÷"æçVÖ&W"â×6v&÷ÂgV÷C´4ôÒFW7BgV÷C²ÂgV÷CµvRçFW&6WFVB4ôÒW'&÷"b333²gV÷C²fײ5$Äbfײ5$Äbfײð gV÷C¶W'"æFW67&Föâ3¢gV÷C²fײD"fײb33c¶ô×W'&÷"æFW67&Föâfײ5$Äbfײð gV÷C¶W'"çvæFW67&Föã¢gV÷C²fײD"fײb33c¶ô×W'&÷"çvæFW67&Föâfײ5$Äbfײð gV÷C¶W'"æçVÖ&W"3¢gV÷C²fײD"fײb33c´WçVÖ&W"fײ5$Äbfײð gV÷C¶W'"æÆ7FFÆÆW'&÷"3¢gV÷C²fײD"fײb33c¶ô×W'&÷"æÆ7FFÆÆW'&÷"fײ5$Äbfײð gV÷C¶W'"ç67&FÆæR3¢gV÷C²fײD"fײb33c¶ô×W'&÷"ç67&FÆæRfײ5$Äbfײð gV÷C¶W'"ç6÷W&6R3¢gV÷C²fײD"fײb33c¶ô×W'&÷"ç6÷W&6Rfײ5$Äbfײð gV÷C¶W'"æVÇfÆR3¢gV÷C²fײD"fײb33c¶ô×W'&÷"æVÇfÆRfײ5$Äbfײð gV÷C¶W'"æVÇ6öçFWB3¢gV÷C²fײD"fײb33c¶ô×W'&÷"æVÇ6öçFWBð ¢6WDW'&÷"²Fò6V6²f÷"gFW"F2gVæ7Föâ&WGW&ç0¤VæFgVæ
These are the "Swiss Army knife" tools which help you get started.
Windows Script Component Wizard
WSH & WSC Scripts for SciTE
Generating a type library for the specified WSC file
' Generating a type library for the specified WSC file. ' The script assumes to be invoked through a context menu ' and to receive the WSC name on the command line. ' --------------------------------------------------------------- ' Get the WSC file name to work with If WScript.Arguments.Count = 0 Then wscFile = InputBox ("Enter the WSC file name:", "WSC") Else wscFile = WScript.Arguments.Item(0) End If if wscFile = "" Then WScript.Quit ' Instantiate the object to create the typelib Set oTL = CreateObject("Scriptlet.TypeLib") ' Set source and target file names oTL.AddURL wscFile tlbFile = Replace(wscFile, ".wsc", ".tlb", 1, -1, 1) oTL.Path = tlbFile ' Set the name to appear in the Object Browser posSlash = InStrRev(wscFile, "\") posDot = InStrRev(wscFile, ".") wscFileOnly = Mid(wscFile, posSlash+1, posDot-posSlash-1) oTL.Name = wscFileOnly & "TLB" ' Get the description defDesc = wscFileOnly & " Type Library" desc = InputBox ("Enter the TypeLib description", "WSC Description", defDesc) If desc <> "" Then oTL.Doc = desc Else oTL.Doc = defDesc End If ' Write the TypeLib oTL.Write oTL.Reset
This give everyone a possibility to create there own COM objects
and benifit from all these advantages :
Enjoy your first custom COM object !!- Create you own custom COM objects.
- Reuse your AU3 UDF's in other COM compliant applications
- No need to translate AU3 UDF's to other script languages
- FULL exposure of all AU3 commands and functions :
- supports methode, properties and events
- supports parameter functions and variables (Tested)
- supports standard UDF's with return values (Tested)
- supports AU3 GUI controls (Tested)
- supports DLLcall UDF's (Tested)
- supports UDF's including other COM objects, cascading COM calls (Tested)
- supports multidirectional COM communication (Tested)
- supports reuse of the custom COM opjects in other COM compliant application (Tested)
- supports write back functionality (Not Tested)
- Easy and on the fly debugging of the custom COM objects, using notepad
- Easy and on the fly extendible custom COM objects, using notepad
- Easy distribution of the COM objects, everything it is text based.
..No need to compile DLL's and distribute.
- No need to have an AutoIT full install, on the destination system.
..Only need to have the "AutoIt3.exe" distributed.
- Windows platform independend (as of Windows 98 and later)
..No need to register an <script language="AutoIT"> namespace on the system, to run it.
- Which makes it more transparant and portable to other systems.
- Ease reuse of NON AU3, scripts as COM objects in AutoIT
..Supporting COM interfaces from JScript, Microsoft® Visual Basic® Scripting Edition (VBScript), PERLScript, PScript, and Python to AU3.
- Easy to generate a TypeLibrary files, from the custom COM objects, for use in COM compliant apps.
..supporting the MS Intellisence technology
- Support for VB CreateObject LATE and EARLY Bindings.
..Provided that you have a type library for the scriptlet, you can employ early binding as well.
- Small footprint perfect marriage for AutoIT
- ...
Happy scripting in 2007
ptrex
Attached Files
Edited by ptrex, 15 January 2007 - 10:15 AM.






