Jump to content

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


Recommended Posts

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.

 

Link to post
Share on other sites

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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 2 weeks later...

:) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...