VeeDub Posted April 20, 2007 Share Posted April 20, 2007 (edited) Hi, I have been reading the help on COM objects and in particular the section about Oleview and IDispatch. Having read the help I am not sure whether I can use AutoIt with this COM object as the IDispatch does not appear to list any Methods. However as I am new to COM objects I thought I would confirm my suspicion. Would appreciate if someone knowledgeable about COM can review the following screenshots and advise whether it is possible to work with this COM object via AutoIt Thanks VW Edited April 22, 2007 by VeeDub Link to comment Share on other sites More sharing options...
lod3n Posted April 20, 2007 Share Posted April 20, 2007 It does have inherited methods, which you should be able to use. It would be something like:$oSbi = objCreate("Sbimgmnt.ShellExt") $oSbi.invoke() $oSbi.GetIDsOfName($parameter) Something like that. I can't really tell you much more than that without more information. What is this object, and where is it from, what does it do? [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
ptrex Posted April 20, 2007 Share Posted April 20, 2007 @allMaybe this can give you a hintShadowStorrepgards,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...
VeeDub Posted April 21, 2007 Author Share Posted April 21, 2007 (edited) Something like that. I can't really tell you much more than that without more information. What is this object, and where is it from, what does it do?Hi lod3n, ptrex is right, it is ShadowProtect Desktop Edition, it is a disk imaging program (like Ghost - but better). What it does, it does quite well, but the scheduling options don't do exactly what I want and I found a set of vbs scripts which demonstrate that Shadow can be controlled via a script so I thought I would see if I could use AutoIt instead. Although I have done a little bit of programming via COM in the past with Outlook, I never fully understood how to identify the methods that were available, have to say that whoever wrote the COM intro in the help did an excellent job, that is a great primer. But if you look at the example with Explorer and the Methods available via IDispatch ... Explorer has many listed where Shadow only has a few - and they're listed in the Inherited Interfaces. So far I have not managed to "convert" any of the VBS script - and in fact I've discovered that the example VBS scripts don't work either Having had a close look at the example VBS scripts I think they may be for an earlier version of ShadowDesktop as they do not appear to reference the correct object. Here is an example Set stdOut = WScript.Stdout Set Scheduler = CreateObject ("ShadowStor.ShadowProtect") StdOut.Write "There is(are) " & Scheduler.Jobs.Count & " job(s) in the service ShadowProtect" & vbCrLf Which fails with: Line: 5 Char: 1 Error: The handle is invalid Code: 80070006I have not been able to find much about that error, but I think the CreateObject statement is wrong so changed it too: Set stdOut = WScript.Stdout Set Scheduler = CreateObject ("Sbimgmnt.ShellExt") StdOut.Write "There is(are) " & Scheduler.Jobs.Count & " job(s) in the service ShadowProtect" & vbCrLf Which fails with: Line: 5 Char: 1 Error: Object doesn't support this property or method: Scheduler.Jobs Code: 800A01B6This makes me question whether I can use COM to work with Shadow, although you would think it would be strange for them to remove that function. I sent them an e-mail, but they have responded by saying that scripting is un-supported. So now it's a challenge basically. Cheers, VW Edited April 21, 2007 by VeeDub Link to comment Share on other sites More sharing options...
VeeDub Posted April 21, 2007 Author Share Posted April 21, 2007 @allMaybe this can give you a hintShadowStorrepgards,ptrexHi ptrex,I was not aware of that patch, I will try that and see how I go.ThanksVW Link to comment Share on other sites More sharing options...
VeeDub Posted April 21, 2007 Author Share Posted April 21, 2007 Here is a Type Library Viewer that I came across. It is free and IMO it has a better interface to Type Library objects than OleView. Link to comment Share on other sites More sharing options...
VeeDub Posted April 22, 2007 Author Share Posted April 22, 2007 I have worked out how to access the Type Library. Here is a vb script: Set stdOut = WScript.Stdout Set oShadow = CreateObject ("ShadowStor.ShadowProtect") StdOut.Write "There are " & oShadow.Jobs.Count & " job(s) in the service ShadowProtect" & vbCrLf For Each Job in oShadow.Jobs StdOut.Write vbCrLf & "Job " & Job.ID & vbCrLf For Each Task in Job.Tasks StdOut.Write " Task " & Task.TaskID StdOut.Write vbCrLf Task.GetParameters TaskType, TaskOptions, TaskFlags, Source, Dst, Comment, CompressLvl, CryptoLvl if TaskType=1 or TaskType=5 Then StdOut.Write " Backup from " & Source & " to " & Dst & vbCrLf StdOut.Write " Compress level " & CompressLvl & " Crypto level " & CryptoLvl end if StdOut.Write vbCrLf Next StdOut.Write vbCrLf Next Here is the corresponding AutoIt code: $oShadow = objCreate("ShadowStor.ShadowProtect") ConsoleWrite("There are " & $oShadow.Jobs.Count & " job(s) in the service ShadowProtect" & @CRLF) For $oJob in $oShadow.Jobs ConsoleWrite( @CRLF & "Job " & $oJob.ID & @CRLF) For $oTask in $oJob.Tasks ConsoleWrite(" Task " & $oTask.TaskID & @CRLF) Next Next I have not yet been able to figure out the equivalent AutoIt syntax for the following vbscript statement: Task.GetParameters TaskType, TaskOptions, TaskFlags, Source, Dst, Comment, CompressLvl, CryptoLvl if TaskType=1 or TaskType=5 Then StdOut.Write " Backup from " & Source & " to " & Dst & vbCrLf StdOut.Write " Compress level " & CompressLvl & " Crypto level " & CryptoLvl end if This AutoIt syntax sort of works: $oTask.GetParameters("TaskType","TaskOptions","TaskFlag", "Source","Destination","Comment", "CompressLevel","CryptoLevel") In that the AutoIt script does not error on this line, but when I try to use the resulting objects. For example; if $oTask.TaskType then I get Member not found. I have also tried the following without success, these two error: $oTaskType = $oTask.GetParameters.TaskType $oTaskType = $oTask.GetParameters("TaskType") This does not error, but I don't get any results: $TaskType = $oTask.GetParameters("TaskType","","", "","","", "","") GetParameters is reported as a SubProcedure by the Type Library viewer, which suggests to me that the correct syntax to use to call GetParameters is the line above which does not error, but what is not clear to me is how I access the results after the call. In the vbscript example, the objects are available after the call, but in AutoIt they're not. Would appreciate suggestions on arguments to try. Thanks VW Link to comment Share on other sites More sharing options...
DaleHohm Posted April 22, 2007 Share Posted April 22, 2007 there area couple of threads about dictionary objects. Sven had to make some fixes to make them accessible... it may help to read up on them... 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 More sharing options...
VeeDub Posted April 22, 2007 Author Share Posted April 22, 2007 there area couple of threads about dictionary objects. Sven had to make some fixes to make them accessible... it may help to read up on them... DaleHi Dale, If this is the post you're referring to, then I have tried the latest beta and it makes no difference. I don't think that this is a bug, it seems that vbscript has if you like a "super function" capability. If you have a look at the vbscript statement Task.GetParameters TaskType, TaskOptions, TaskFlags, Source, Dst, Comment, CompressLvl, CryptoLvl After that single line of code the vbscript has access to the values in all of those variables, , to the best of my knowledge AutoIt does not have an equivalent statement. I've attached a screenshot from the Type Library viewer of GetParameters VWGetParameters.bmp Link to comment Share on other sites More sharing options...
DaleHohm Posted April 22, 2007 Share Posted April 22, 2007 Have you tried: $oTask.GetParameters( $TaskType, $TaskOptions, $TaskFlags, $Source, $Dst, $Comment, $CompressLvl, $CryptoLvl) Studying the VBScript, that is the syntax I would guess... 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 More sharing options...
VeeDub Posted April 23, 2007 Author Share Posted April 23, 2007 Have you tried: $oTask.GetParameters( $TaskType, $TaskOptions, $TaskFlags, $Source, $Dst, $Comment, $CompressLvl, $CryptoLvl) Studying the VBScript, that is the syntax I would guess... DaleHi Dale, No I had not. Looking at the Type Library view of GetParameters as there was no use of ByVal in GetParameters I could not see how the variables could be updated. On the other hand, looking at the vbscript you're right it was worth trying. This is the code I added: $oTask.GetParameters($TaskType,$TaskOptions,$TaskFlag, $Source,$Destination,$Comment,$CompressLevel,$CryptoLevel) ConsoleWrite("TaskType: " & $TaskType & @CRLF & "TaskOptions: " & $TaskOptions & @CRLF & "TaskFlag: " & $TaskFlag & @CRLF & _ "Source: " & $Source & @CRLF & "Dest: " & $Destination & @CRLF & "Comment: " & $Comment & @CRLF & _ "Compression: " & $CompressLevel & @CRLF & "Crypto: " & $CryptoLevel) No error, but nothing reported in any of these variables either, and there is a job and it does have values in at least some of these variables. It's not that important, but since I had got some of the code working, it would have been nice if it was possible to work with all the objects. For some, no doubt logical reason, it looks like it is broken. Shit happens. Thanks VW Link to comment Share on other sites More sharing options...
DaleHohm Posted April 23, 2007 Share Posted April 23, 2007 Another option to consider would be to instatiate a ScriptControl object using VBScript as the language. This could also help you potentially find a workaround in pure AutoIt. See here for an example to get started: http://www.autoitscript.com/forum/index.ph...st&p=301771Dale 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 More sharing options...
VeeDub Posted April 24, 2007 Author Share Posted April 24, 2007 I was not aware of this option. Here is my attempt $oMyError = ObjEvent("AutoIt.Error","MyErrHandler"); Install a custom error handler $oShadow = ObjCreate("ShadowStor.ShadowProtect") $vbs = "Function ShowJobs()" $vbs = $vbs & @CRLF & 'oShadow.Jobs.Count' $vbs = $vbs & @CRLF & 'End Function' $oSC = ObjCreate("ScriptControl") $oSC.language = "vbscript" MsgBox(0,"VBS",$vbs) $oSC.addcode($vbs) $vboutput = $oSC.run("ShowJobs") ConsoleWrite($vboutput) Func MyErrHandler() $ErrorScriptline = $oMyError.scriptline $ErrorNumberHex = Hex($oMyError.number, 8) $ErrorWinDescription = $oMyError.WinDescription $ErrorOutput = "" $ErrorOutput = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & " " $ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & " " $ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & " " $ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & " " MsgBox(0,"Error Output",$ErrorOutput) SetError(1) Return EndFunc It errors on this line $vboutput = $oSC.run("ShowJobs") With errorHex: 80020009 I originally had the vbs equivalent of this line in the function $oShadow = ObjCreate("ShadowStor.ShadowProtect") I assume that $oShadow and oShadow in VBS will be recognised as the same, in any event the script error was the same either way. VW Link to comment Share on other sites More sharing options...
DaleHohm Posted April 24, 2007 Share Posted April 24, 2007 I assume that $oShadow and oShadow in VBS will be recognised as the same, in any event the script error was the same either way.Context is not automatically shared between AutoIt and the ScriptControl, so no, this is not a valid assumption. You can only share what you explicitly pass between the two contexts... the ScriptControl DOES continue to run and maintain its state however, so you can continue to send commands to it and it remembers where it was the last time you accessed it. This is why I use .eval incrementally instead of using .run -- suggest you try the same.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 More sharing options...
VeeDub Posted April 28, 2007 Author Share Posted April 28, 2007 Hi Dale,I have spent some time looking for examples that I could use as a starting point, using your suggested approach it is not clear to me how to pass the $oShadow object as I think I need to call a vbscript function so that I can pass $oShadow, but all the examples I have found use .run rather than .evalBut for your comment about using.eval incrementallythe way I would approach this task using vbscript would be something like this example here. I would appreciate it if you could show me how to pass $oShadow (the handle to the COM object) to the vbscript using your approach. Alternatively if there is another thread which would be useful as a guide, that would be helpful.Thanks,VW Link to comment Share on other sites More sharing options...
DaleHohm Posted April 28, 2007 Share Posted April 28, 2007 I'm not an expert on the ScriptControl and your question prompted me to learn a little more... documentation and examples for it are scarce. It turns out there is an addObject mothod that appears to be the preferred way of passing an object. Here is a working example: #include <IE.au3> $oIE = _IECreate("www.google.com") $oSC = ObjCreate("ScriptControl") $oSC.language = "VBScript" $oSC.addObject("oIE", $oIE) $oSC.eval('oIE.navigate ("http://www.autoitscript.com")') 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 More sharing options...
VeeDub Posted April 28, 2007 Author Share Posted April 28, 2007 Thanks Dale, using that approach this script now works $oShadow = ObjCreate("ShadowStor.ShadowProtect") $oSC = ObjCreate("ScriptControl") $oSC.language = "vbscript" $oSC.addobject("oShadow",$oShadow) $s1 = $oSC.eval ("oShadow.Jobs.Count") ConsoleWrite("VB Jobs Count: " & $s1 & @CRLF) I will now look at writing a script that uses the example vbscript code to access GetParamaters and we will see whether it works. VW Link to comment Share on other sites More sharing options...
VeeDub Posted April 28, 2007 Author Share Posted April 28, 2007 Dale, This script$oShadow = ObjCreate("ShadowStor.ShadowProtect") $oSC = ObjCreate("ScriptControl") $oSC.language = "vbscript" $oSC.addobject("oShadow",$oShadow) for $oJob In $oShadow.Jobs ConsoleWrite("ID: " & $oJob.ID & @CRLF & _ "Desc: " & $oJob.Description & @CRLF & _ "Status: " & $oJob.Status & @CRLF & _ "Type: " & $oJob.Type & @CRLF) for $oTask In $oJob.Tasks ConsoleWrite("Task: " & $oTask.TaskID & @CRLF & _ "Status: " & $oTask.Status & @CRLF) $oSC.addobject("oTask",$oTask) $s2 = $oSC.eval("oTask.GetParameters TaskType, TaskOptions, TaskFlags, Source, Destination, Comment, CompressLvl, CryptoLvl") ConsoleWrite("GetParameters: " & $s2) Next Next Fails at this line $s2 = $oSC.eval("oTask.GetParameters TaskType, TaskOptions, TaskFlags, Source, Destination, Comment, CompressLvl, CryptoLvl") with 80020009 Does the script logic look OK to you? That error could be because the library does not work properly, which from one perspective seems unlikely with a commercial product, but on the other hand would explain why the COM object is "unsupported". Then again StorageCraft may just be seeking to avoid complex support questions which would also be understandable. Link to comment Share on other sites More sharing options...
VeeDub Posted April 28, 2007 Author Share Posted April 28, 2007 This script works:$oShadow = ObjCreate("ShadowStor.ShadowProtect") $oSC = ObjCreate("ScriptControl") for $oJob In $oShadow.Jobs $oSC.addobject("oJob",$oJob) $s2 = $oSC.eval("oJob.Description") ConsoleWrite("Job desc via vb script: " & $s2 & @CRLF) for $oTask In $oJob.Tasks $oSC.addobject("oTask",$oTask) $s3 = $oSC.eval("oTask.TaskID") ConsoleWrite("TaskID: " & $s3 & @CRLF) ; $s4 = $oSC.eval("oTask.GetParameters TaskType, TaskOptions, TaskFlags, Source, Destination, Comment, CompressLvl, CryptoLvl") Next NextNote:I had to leave a line out of the above code $oSC.language = "vbscript"because for some reason everytime I added this line, half of the remaining code disappeared from my post Really weird, the whole snippet is in the reply box but the code gets mangled in the preview.When I uncomment the line $s4 = $oSC.eval("oTask.GetParameters ...I get error 80020009But as the statementoTask.GetParameters...is straight from the vbscript example, the GetParameters function must be broken.@Dale - thanks a bunch for your help with this.VW Link to comment Share on other sites More sharing options...
DaleHohm Posted April 28, 2007 Share Posted April 28, 2007 I think that GetParameters may not have an overall return value, but instead returns into each of the variable names you specify. So instead of $s2 = $oSC.eval("oTask.GetParameters TaskType, TaskOptions, TaskFlags, Source, Destination, Comment, CompressLvl, CryptoLvl") try $oSC.eval("oTask.GetParameters TaskType, TaskOptions, TaskFlags, Source, Destination, Comment, CompressLvl, CryptoLvl") $TaskType = $oSC.eval("TaskType") ConsoleWrite("TaskType: " & $TaskType & @CR) You'll need to find the docs for GetParameters to see what kind of data is passed back for each element - TaskOptions and TaskFlags I would guess to be arrays and you may have to examine them on the VBS side. 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 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