Jump to content

COM and application enumerations


Recommended Posts

My apologies in advance, I'm not quite sure how to pose this question.

What I'm trying to figure out is if there is a way to make application-specific enumerated constants available to AutoIt when using the new COM interface?

What I've been doing to date is figuring out the current static value from the application and defining constants in my scripts.

Is there a way to do this dynamically?

Thanks,

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I think what you're asking is if AutoIt can be a COM server which afaik it can't be. But things may change once ActiveX gets implemented.

Edit: apparently ActiveX developement is off so...

Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

OK, I'm making progress here. I found a code example in VBScript that finds the enums in the typelibs and created include files for VBS or JS. I've modified it to create include files in AutoIt3 syntax as well... it works pretty slick.

I've tried to conver it to AU3 format, but have run into a problem with ObjCreate("TLI.TLIApplication") that I'll post in another thread (and hopefully Sven will be able to have a look).

It creates code that looks like this:

;************************************************************
;Enumerated Constants for CoClass "Excel.Application"
;Extracted from "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE"
;************************************************************

;Constants
Const $xlAll = -4104
Const $xlAutomatic = -4105
Const $xlBoth = 1
Const $xlCenter = -4108
etc. etc. etc.

VBScript code follows:

Option Explicit 

Dim fs 
Set fs = CreateObject("Scripting.FileSystemObject") 

'Create IncludeFiles 
'CreateIncludeFile "Excel.Application", "vbs", "C:\xlsConsts.vbs", false
'CreateIncludeFile "Excel.Application", "js",  "C:\xlsConsts.js", false
CreateIncludeFile "Excel.Application", "au3", "C:\xlsConsts.au3", true 
'CreateIncludeFile "MindManager.Application", "au3", "C:\MindManagerConsts.au3", false

Sub CreateIncludeFile (sProgID, scrID, sOutFile, bShowImmediate) 
  Dim strConsts 
  strConsts = ReturnTlbEnumsFromProgId (sProgID, scrID) 
  fs.CreateTextFile(sOutFile, true, 0).Write strConsts 
  If bShowImmediate Then CreateObject("WScript.Shell").Run "notepad " & sOutFile 
End Sub 


Function ReturnTlbEnumsFromProgId (sProgId, scrID) 
  Dim TLA, TLI, CstEnum, CstObj, CstString, CoCls, vCst, vEndl, vCmt, vPre 
  Set CoCls = CreateObject(sProgId) 
  Set TLA   = CreateObject("TLI.TLIApplication") 
  Set TLI   = TLA.InterfaceInfoFromObject(CoCls).Parent 
  Call getLangParams (scrID, vCst, vEndl, vCmt, vPre) 
  CstString = BuildIntro (sProgId, TLI.ContainingFile, vCmt) 
  For each CstEnum in TLI.Constants 
    If "_" <> Left(CstEnum.Name, 1) Then 
      CstString = CstString & vbCrlf & vCmt & CstEnum.Name & vbCrlf 
      For Each CstObj In CstEnum.Members 
        CstString = CstString & vCst & " " & vPre & CstObj.Name _ 
                  & " = " & CstObj.Value & vEndl & vbCrLf 
      Next 
    End If 
  Next 
  ReturnTlbEnumsFromProgId = CstString 
End Function 


Sub getLangParams (ByVal scrID, ByRef vCst, ByRef vEndl, ByRef vCmt, ByRef vPre) 
  Select Case LCase(scrID) 
    Case "vbs", "vbscript": 
      vCst  = "Const" : vEndl = ""   : vCmt = "'" : vPre = ""
    Case "js", "jscript": 
      vCst  = "var"   : vEndl = ";"  : vCmt = "//" : vPre = ""
    Case "au3", "autoit3":
      vCst  = "Const" : vEndl = ""   : vCmt = ";" : vPre = "$"
    Case Else 
      vCst  = ""      : vEndl = ""   : vCmt = ""  : vPre = ""
    End Select 
End Sub 


Function BuildIntro (sProgId, srv, vCmt) 
  BuildIntro = vCmt & String (60, "*") & vbCrLf _ 
    & vCmt & "Enumerated Constants for CoClass """ & sProgID & """" & vbCrLf _ 
    & vCmt & "Extracted from """ & srv & """" & vbCrLf _ 
    & vCmt & String (60, "*") & vbCrLf 
End Function

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...