Jump to content

Gimagex_com.dll: How to manage events with ObjEvent?


Recommended Posts

Hi,

I do not understand what happened. Here's my post more readable ...

Hi,

I'm making my first script witch use COM/dll. I want to transcribe this vbscrip into an Autoit script (help file gimagex.chm can be found in the downloads here):

Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl", "objWIM_")

objWIM.Source = "c:\test"
objWIM.Destination = "test.wim"
objWIM.ImageName = "Test WIM"
objWIM.Description = "Test Description"
objWIM.DisplayName = ""
objWIM.DisplayDescription = ""
objWIM.Flags = "Ultimate"
objWIM.Check = TRUE
objWIM.Verify = TRUE
objWIM.Bootable = FALSE

objWIM.CaptureImage

WScript.DisconnectObject objWIM 
Set objWIM = Nothing

Sub objWIM_Progress(Percent, TimeRemaining)
    WScript.Echo Percent & "% - " & TimeRemaining & " sec(s)"
    ' Abort the operation by using the line below
 'objWim.Abort = TRUE
End Sub

Sub objWIM_ProgressInfo(Info)
 WScript.Echo Info
End Sub

Here is my Autoit code:

$objWIM = ObjCreate("GimageX.GimageXCtrl")
If Not IsObj($objWIM) Then
    Runwait("regsvr32.exe /s gimagex_com.dll")
    $objWIM = ObjCreate("GimageX.GimageXCtrl")
    If Not IsObj($objWIM) Then
        MsgBox(0, "Error", "$objWIM isn't a valid Object.")
        Exit
    EndIf
EndIf

$obj_evenement = ObjEvent($objWIM, "WimEvent_")
If @error Then
    MsgBox(0, "AutoIt COM Test", _
        "WimEvent have this error: " & Hex(@error, 8))
    Exit
EndIf

$Compression_rate = 2

With $objWIM
    .Source = "c:\test"
    .Destination = "c:\test2\test" & $Compression_rate & ".wim"
    .ImageName = "Test WIM"
    .Description = "Test Description"
    .Compression = $Compression_rate
    .DisplayName = ""
    .DisplayDescription = ""
    .Flags = ""
    .Check = True
    .Verify = True
    .Bootable = False
EndWith

ProgressOn("Compilation", "Compilation progression")
$objWIM.CaptureImage

$obj_evenement.stop
$obj_evenement = 0
$objWIM = 0
ProgressOff()

Func WimEvent_Progress($Percent, $TimeRemaining)
    If $Percent >= 0 And $Percent <= 100 Then
        ProgressSet($Percent, $Percent & " percent to go.", "It remaine nearly " & $TimeRemaining & " sec(s)")
    EndIf
    ;Abort the operation by using the line below
    ;$objWim.Abort = TRUE
EndFunc ;==>WimEvent_Progress

Func WimEvent_ProgressInfo($Info)
    SplashTextOn("Compilation progression", $Info)
    Sleep(2000)
    SplashOff()
EndFunc ;==>WimEvent_ProgressInfo

The script makes the wim file very well with maximum, fast and non compression rate. But I can't find a way to get events for showing the progress and remaining time. Someone can help me to fix it? Thanks!

MDV

Edited by MadDogVachon

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

Do the event functions get called at all? Are there any errors? Can you add a COM Error handler? Any output to the SciTE console (i.e. "The use of this object failed...")?

:(

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

@MadDogVachon

This Dll has 2 events called Progress and ProgessInfo

Maybe this can help

$obj_evenement = ObjEvent($objWIM, "MYEvent_")

Code here ...

Func MYEvent_Progress($Percent, $TimeRemaining)
    If $Percent >= 0 And $Percent <= 100 Then
        ProgressSet($Percent, $Percent & " percent to go.", "It remaine nearly " & $TimeRemaining & " sec(s)")
    EndIf
    ;Abort the operation by using the line below
    ;$objWim.Abort = TRUE
EndFunc ;==>WimEvent_Progress

unc MYEvent_ProgressInfo($Info)
    SplashTextOn("Compilation progression", $Info)
    Sleep(2000)
    SplashOff()
EndFunc ;==>WimEvent_ProgressInfo

Not tested I don't have the Dll registered.

rgds

ptrex

Link to comment
Share on other sites

@MadDogVachon

This Dll has 2 events called Progress and ProgessInfo

It looked to me like he already had both covered with WimEvent_Progress() and WimEvent_ProgressInfo(). What did I miss?

:(

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

Do the event functions get called at all? Are there any errors? Can you add a COM Error handler? Any output to the SciTE console (i.e. "The use of this object failed...")?

:(

Thanks for helping!

The event function don't give nothing, error or something else. So there's no error except the progression bar don't move and none information shown. If i have some error I can try to make some COM error handler.

Here is the output of Scite console (no error):

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "V:\XP Virtuel\gimagex\Gimagex_COM.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams  
+>12:20:10 Starting AutoIt3Wrapper v.2.0.0.1 Environment(Language:040C Keyboard:00001009 OS:WIN_XP/Service Pack 2 CPU:X86 OS:X86)
>Running AU3Check (1.54.19.0) from:C:\Program Files\AutoIt3
+>12:20:10 AU3Check ended.rc:0
>Running:(3.3.4.0):C:\Program Files\AutoIt3\autoit3.exe "V:\XP Virtuel\gimagex\Gimagex_COM.au3" 
+>12:20:16 AutoIT3.exe ended.rc:0
+>12:20:17 AutoIt3Wrapper Finished
>Exit code: 0   Time: 7.291

I have nothing else to give except all information gave by Jon in gimagex.chm. Here are these:

[b]GImageX COM Installation[/b]
    Before you can use the COM interface to GImageX it needs to be "registered".

    To register the COM interface:

    1. Ensure that the gimagex_com.dll file is located in the same folder as wimgapi.dll from the Windows Automated Installation Kit (WAIK).

    2. Open a command prompt.

    3. Change directory (using CD) to the directory that contains gimagex_com.dll.

    4. Type regsvr32.exe gimagex_com.dll and press enter.

    The name of the GImageX control is GImageX.GImageXCtrl

    All examples are given for VBScript.


[b]Method Reference (COM)[/b]

    [i]AppendImage [/i]
        --------------------------------------------------------------------------------

        Captures and appends an image to an existing WIM file.

        AppendImage()

        Parameters

        Set the following properties before calling:
        Source The source folder to capture. 
        Destination The name of the WIM file to capture to. 
        ImageName Name of the image. 
        Description Description of the image. 
        DisplayName Display name of the image (used in Vista setup for display purposes). 
        DisplayDescription Display description of the image (used in Vista setup for display purposes). 
        Flags "", "Ultimate", etc. 
        Check Set to TRUE to add integrity information. 
        Verify Set to TRUE to Verify the data captured. 
        Bootable Set to TRUE to make this image bootable. 

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        Remarks

        None.

        Related

        CaptureImage 
 

        Example

    Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl", "objWIM_")

    objWIM.Source = "c:\test"
    objWIM.Destination = "test.wim"
    objWIM.ImageName = "Test WIM"
    objWIM.Description = "Test Description"
            objWIM.DisplayName = ""
            objWIM.DisplayDescription = ""
            objWIM.Flags = "Ultimate"
            objWIM.Check = TRUE
            objWIM.Verify = TRUE
            objWIM.Bootable = FALSE

            objWIM.AppendImage

            WScript.DisconnectObject objWIM 
            Set objWIM = Nothing

            Sub objWIM_Progress(Percent, TimeRemaining)
                WScript.Echo Percent & "% - " & TimeRemaining & " sec(s)"
                ' Abort the operation by using the line below
                'objWim.Abort = TRUE
            End Sub

            Sub objWIM_ProgressInfo(Info)
                WScript.Echo Info
            End Sub


    [i]ApplyImage [/i]
        --------------------------------------------------------------------------------

        Applies a WIM image to a folder.

        ApplyImage()

        Parameters

        Set the following properties before calling:
        Source The source WIM file to apply. 
        Destination The destination folder to apply the image to. 
        ImageIndex The image index of the image to apply. 
        Check Set to TRUE to check integrity information. 
        Verify Set to TRUE to Verify the data applied. 

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        Remarks

        None.

        Related

        AppendImage, CaptureImage 

        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl", "objWIM_")

            objWIM.Source = "test.wim"
            objWIM.Destination = "c:\test"
            objWIM.ImageIndex = 1
            objWIM.Check = TRUE
            objWIM.Verify = TRUE
            objWIM.ApplyImage

            WScript.DisconnectObject objWIM
            Set objWIM = Nothing

            Sub objWIM_Progress(Percent, TimeRemaining)
                WScript.Echo Percent & "% - " & TimeRemaining & " sec(s)"
                ' Abort the operation by using the line below
                'objWim.Abort = TRUE
            End Sub

            Sub objWIM_ProgressInfo(Info)
                WScript.Echo Info
            End Sub
        

    [i]CaptureImage[/i]
        --------------------------------------------------------------------------------

        Captures an image to an existing WIM file.

        CaptureImage()

        Parameters

        Set the following properties before calling:
        Source The source folder to capture. 
        Destination The name of the WIM file to capture to. 
        ImageName Name of the image. 
        Description Description of the image. 
        DisplayName Display name of the image (used in Vista setup for display purposes). 
        DisplayDescription Display description of the image (used in Vista setup for display purposes). 
        Flags "", "Ultimate", etc. 
        Check Set to TRUE to add integrity information. 
        Verify Set to TRUE to Verify the data captured. 
        Bootable Set to TRUE to make this image bootable. 

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        Remarks

        None.

        Related

        AppendImage 

        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl", "objWIM_")

            objWIM.Source = "c:\test"
            objWIM.Destination = "test.wim"
            objWIM.ImageName = "Test WIM"
            objWIM.Description = "Test Description"
            objWIM.DisplayName = ""
            objWIM.DisplayDescription = ""
            objWIM.Flags = "Ultimate"
            objWIM.Check = TRUE
            objWIM.Verify = TRUE
            objWIM.Bootable = FALSE

            objWIM.CaptureImage

            WScript.DisconnectObject objWIM 
            Set objWIM = Nothing


            Sub objWIM_Progress(Percent, TimeRemaining)
                WScript.Echo Percent & "% - " & TimeRemaining & " sec(s)"
                ' Abort the operation by using the line below
                'objWim.Abort = TRUE
            End Sub

            Sub objWIM_ProgressInfo(Info)
                WScript.Echo Info
            End Sub
            

    [i]GetImageInfo [/i]
        --------------------------------------------------------------------------------

        Retrieves information about an image.

        GetImageInfo()

        Parameters

        Set the following properties before calling:
        Source The source WIM file. 
        ImageIndex The image index for the required image. 

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        After a successful call the following properties will contain information:
        XML
        ImageName
        Description
        Flags
        FileCount
        DirCount

        Remarks

        None.

        Related

        GetWIMInfo 

        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl")
            objWIM.Source = "test.wim"
            objWIM.ImageIndex = 1
            objWIM.GetImageInfo
            WScript.Echo objWIM.XML
            WScript.Echo objWIM.ImageName
            WScript.Echo objWIM.Description
            WScript.Echo objWIM.DisplayName
            WScript.Echo objWIM.DisplayDescription
            WScript.Echo objWIM.Flags
            WScript.Echo objWIM.FileCount
            WScript.Echo objWIM.DirCount

            Set objWIM = Nothing


    [i]GetOpenFileName [/i]
        --------------------------------------------------------------------------------

        Gets an existing filename.

        GetOpenFileName()

        Parameters

        None.

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        After a successful call the following properties will contain information:
        FileName

        Remarks

        None.

        Related

        GetSaveFileName 

        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl")

            objWIM.GetOpenFileName
            WScript.Echo objWIM.FileName

            Set objWIM = Nothing


    [i]GetSaveFileName [/i]
        --------------------------------------------------------------------------------

        Gets a filename to save to.

        GetSaveFileName()

        Parameters

        None.

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        After a successful call the following properties will contain information:
        FileName

        Remarks

        None.

        Related

        GetOpenFileName 
 
        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl")

            objWIM.GetSaveFileName
            WScript.Echo objWIM.FileName

            Set objWIM = Nothing


    [i]GetWIMInfo [/i]
        --------------------------------------------------------------------------------

        Retrieves information about a WIM file.

        GetWIMInfo()

        Parameters

        Set the following properties before calling:
        Source The source WIM file. 

        Return Value

        Success: Returns 0. 
        Failure: Returns non-zero. 

        After a successful call the following properties will contain information:
        XML
        ImageCount
        BootIndex

        Remarks

        None.

        Related

        GetWIMInfo 
 
        Example

            Set objWIM = WScript.CreateObject("GImageX.GImageXCtrl")
            objWIM.Source = "test.wim"
            objWIM.GetWIMInfo
            WScript.Echo objWIM.XML
            WScript.Echo objWIM.ImageCount
            WScript.Echo objWIM.BootIndex

            Set objWIM = Nothing


[b]Properties Reference[/b]
    Below is an list of all the properties available in GImageX.

    Property Read/Write Datatype Description 
    Abort Write BOOL Setting this to TRUE will abort an imaging operation during a Progress event. 
    BootIndex Read LONG The image index of the bootable image in a WIM file as returned by GetWIMInfo. 0 if none. 
    Bootable Write BOOL Sets the image that is captured will be the bootable image in a WIM file. 
    Check Write BOOL Adds integrity check information to a WIM file. 
    Compression Write LONG Sets the compression level for a capture operation. 0=none, 1=fast, 2=highest. 
    Config Write STRING The filename of a wimscript.ini file to use during a CaptureImage or AppendImage operation. 
    Description Read/Write STRING Description of a WIM image. 
    Destination Read/Write STRING The destination file/folder for a imaging operation. 
    DirCount Read LONG Number of directories in a WIM image as returned by GetImageInfo. 
    DisplayDescription Read/Write STRING Display description of a WIM image. 
    DisplayName Read/Write STRING Display name of a WIM image (only usually seen during Vista setup when you choose an image). 
    FileCount Read LONG Number of files in a WIM image as returned by GetImageInfo. 
    FileName Read LONG The filename returned by GetOpenFileName and GetSaveFileName. 
    Flags Read/Write STRING The flags to use in a CaptureImage operation, or as returned by GetImageInfo. 
    ImageIndex Write LONG The image index for a ApplyImage or GetImageInfo operation. 
    ImageCount Read LONG Number of directories in a WIM image as returned by GetWIMInfo. 
    ImageName Read/Write STRING Name of a WIM image. 
    Source Read/Write STRING The source file/folder for a imaging operation. 
    Temp Write STRING The temporary folder to use during a CaptureImage or AppendImage operation. 
    Verify Write BOOL Verify during imaging operations. 
    XML Read STRING The raw XML information as returned by GetImageInfo or GetWIMInfo.

You can retrieve gimagex_com.dll here and wingapi.dll on Windows Vista DVD or Seven DVD in that folder "E:\SOURCES" for DVD drive E:. Gimagex_com.dll need Wingapi.dll in the same folder in order to be registred.

The error must be in that line

$obj_evenement = ObjEvent($objWIM, "WimEvent_")

But I can't figure out what to do.

@ptrex

Thanks for trying to help. PsaltyDS gave you the right response:

MDV

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

Ok, I know now that did not need to download and install VB to run a vbscript.

The vbs works fine for percent progress. So I decide to try this, like the vbscript:

Func WimEvent_Progress($Percent, $TimeRemaining)
    MsgBox(0, "AutoIt Test", $Percent & " percent to go." & " It remaine nearly " & $TimeRemaining & " sec(s)")
EndFunc ;==>WimEvent_Progress

And it's work for the percent but not for time remaining... So the value of $Percent is not a number. So I try this:

Func WimEvent_Progress($Percent, $TimeRemaining)
    $Percent = Number($Percent)
    ProgressSet($Percent, $Percent & " percent to go.", "It remaine nearly " & $TimeRemaining & " sec(s)")
EndFunc ;==>WimEvent_Progress

But I only see the progress when the process finished. Which means 0% to 100% in half second at the end of my Autoit script. So I will try something else.

Thanks for help!

MDV

Edited by MadDogVachon

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

Hi,

The line "$objWIM.CaptureImage" looks like a RunWait... And the functions called by "WimEvent_" look like external functions who don't car about my script...

I tried this:

Func WimEvent_Progress($Percent, $TimeRemaining)
    $Percent = Number($Percent)
    $TimeRemaining = Number($TimeRemaining)
    ProgressOn("Compilation", "Compilation progress")
    ProgressSet($Percent, $Percent & " percent to go.", "It remaine nearly " & $TimeRemaining & " sec(s)")
EndFunc

And I saw the progress bar only at the end and moving fast. I tried with more files to process and the progress bar appears at the end.

For now, I will stay with MsgBox. If someone has better idea, let me know!

MDV

Edited by MadDogVachon

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

Hi,

Ok, I've made others tests with 800Mo of files to process and I notice that vbscript shows messages in real time. My au3 script shows messages at the end of the process regardless if it is with MsgBox or ProgessBar.

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

Hi,

I think that my problem is between gimgex_com.dll and how Autoit manages this dll. The only way I found to show progress, but not a progress bar, is to use this line instead of all the script above:

Runwait(@ComSpec & " /c " & 'imagex /compress maximum /capture c:\Test c:\Test2\.wim "No name for now"', @WorkingDir)

If someone has better idea, I'll take it!

Maybe Jon would know how to solve this problem. He built Autoit and Gimagex, and...

MDV

Mad Dog (Maurice) Vachon, a great Canadian professional wrestler!

Link to comment
Share on other sites

  • 4 years later...

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...