Jump to content
imperialdrag

Help with C# or VB conversion to Autoit (OBJ/COM)

Recommended Posts

imperialdrag

Hello everyone.

I need help converting this C#/VB code to Autoit. 

/// Detailed Visual Studio 2013 C# Example

try{
axMBActX1.InitMBActX(MarkingUnitTypes.MARKINGUNIT_MDX1000);
}catch (System.Runtime.InteropServices.COMException error){
MessageBox.Show(error.Message);
}
/// Simple VB Example

Call MBActX1.InitMBActX(MARKINGUNIT_MDX1000)

My Autoit code. I can't get past the InitMBActX part.

; My Sample Autoit script

Example()

Func Example()
    Local $hGUI = GUICreate("TEST GUI")
    $otest = ObjCreate ("MB3ACTX.MB3ActXCtrl.1")
    $GUIActiveX  = GUICtrlCreateObj ($otest , 10, 10 , 380 , 350 )
    
    $otest.InitMBActX... <==== No idea how to pass the parameters "MarkingUnitTypes" and "MARKINGUNIT_MDX1000" as a valid autoit code
    
EndFunc

axMBActx1, MBActX1 and $otest all refer to the same OBJ class. InitMBActX is the method.  MarkingUnitTypes and MARKINGUNIT_MDX1000 are the arguments.

From the ITypeLib using OLE/COM OBJ viewer.

typedef enum {
    MARKINGUNIT_MDX1000 = 0,
    MARKINGUNIT_MDX1020 = 1,
    MARKINGUNIT_MDX1050 = 2,
    MARKINGUNIT_MDX1500 = 3,
    MARKINGUNIT_MDX1520 = 4
} MarkingUnitTypes;

 

Not sure if this post is for C# or AutoitX section, sorry if I posted in the wrong forum section. Thank you in advance.

 

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

Something like this. To grab COM errors you would need to add a COM error handler to your script. Please check the help file for ObjEvent.

; My Sample Autoit script

Global Enum $MARKINGUNIT_MDX1000, $MARKINGUNIT_MDX1020, $MARKINGUNIT_MDX1050, $MARKINGUNIT_MDX1500, $MARKINGUNIT_MDX1520

Example()

Func Example()
    Local $hGUI = GUICreate("TEST GUI")
    $otest = ObjCreate ("MB3ACTX.MB3ActXCtrl.1")
    $GUIActiveX  = GUICtrlCreateObj ($otest , 10, 10 , 380 , 350 )
    
    $otest.InitMBActX($MARKINGUNIT_MDX1000)
    
EndFunc

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
imperialdrag

The COM error handler is exactly what I needed.  Thank you water.

Share this post


Link to post
Share on other sites
water

:) 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.