Sign in to follow this  
Followers 0
Jazkal

SmartWim code help?

7 posts in this topic

#1 ·  Posted (edited)

I am trying to get SmartWim working with AutoIt3, but I'm having trouble with the progress output.

You can get the smartwim dll here: SmartWim

They give a VBScript example:

Dim objSmartWim, ResultCode
Set objSmartWim = WScript.CreateObject("SmartWim", "objSmartWim_")
objSmartWim.File = "C:\Image.wim"
objSmartWim.Image = "My Test Image"
objSmartWim.Path = "C:\Test"
objSmartWim.Temp = "C:\WINDOWS\Temp"
ResultCode = objSmartWim.CaptureImage(False)
WScript.Echo objSmartWim.GetErrorDescription(ResultCode)
Set objSmartWim = Nothing

Sub objSmartWim_Progress(ByVal nPercent, ByVal nSeconds)
WScript.Echo nPercent & "% complete, " & nSeconds & " remaining"
End Sub

Here is what I have converted to Autoit3 so far:

Dim $objSmartWim
Dim $ResultCode
;$objSmartWim = ObjCreate("SmartWim", "objSmartWim_")
$objSmartWim = ObjCreate("SmartWim")

$objSmartWim.File = "C:\ImageTest.wim"
$objSmartWim.Image = "My Test Image"
$objSmartWim.Path = "C:\Temp"
$objSmartWim.Temp = "C:\WINDOWS\Temp"
$ResultCode = $objSmartWim.CaptureImage(False)
MsgBox(4096, "Test", $objSmartWim.GetErrorDescription($ResultCode), 5)

Any ideas?

Edited by Jazkal

Share this post


Link to post
Share on other sites



I filled out the download form and they sent me a link but it was broken.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here is the one I got from the download link:

EDIT:

I think I need to use ObjEvent, but can't seem to get it to work. Could be wrong though.

Edited by Jon

Share this post


Link to post
Share on other sites

See if this works.

$oSmartWim = ObjCreate("SmartWim")
If @error Then
    MsgBox(64, "Warning", "You must first register the dll.")
    $sFile = FileOpenDialog("Open Dll", @ScriptDir, "DLL (*.dll)", 1, "SmartWim.dll")
    If @error Then
        MsgBox(48, "Error", "Unable to register the dll.")
        Exit
    EndIf
    ShellExecuteWait("regsvr32.exe", '"' & $sFile & '"')
    $oSmartWim = ObjCreate("SmartWim")
    If @error Then
        MsgBox(48, "Error", "Still unable to create SmartWim Object.")
        Exit
    EndIf
EndIf

$oEvent = ObjEvent($oSmartWim, "Evt_")

With $oSmartWim
    .File = "C:\Image.wim"
    .Image = "My Test Image"
    .Path = "C:\Test"
    .Temp = "C:\WINDOWS\Temp"
    $ResultCode = .CaptureImage (False)
EndWith

MsgBox(64, "Result", $oSmartWim.GetErrorDescription ($ResultCode))
$oEvent = 0
$oSmartWim = 0

Func Evt_Progress($nPercent, $nSeconds)
    ToolTip($nPercent & "% complete, " & $nSeconds & " remaining")
EndFunc   ;==>Evt_Progress

Share this post


Link to post
Share on other sites

It creates the WIM file, but doesn't show any progress.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Without a license key I don't have anyway of testing it.

Edit: Figured out I don't need a key so let me try to figure out how to make a .wim file.

Edited by big_daddy

Share this post


Link to post
Share on other sites

I converted your ToolTip to a ProgressOn - Set, and it showed 0% until it was done, then showed 2%, then after clicking on "Ok", it jumps to 9% right before it disappears.

Share this post


Link to post
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
Sign in to follow this  
Followers 0