imperialdrag Posted April 22, 2017 Share Posted April 22, 2017 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 comment Share on other sites More sharing options...
water Posted April 22, 2017 Share Posted April 22, 2017 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
imperialdrag Posted May 1, 2017 Author Share Posted May 1, 2017 The COM error handler is exactly what I needed. Thank you water. Link to comment Share on other sites More sharing options...
water Posted May 1, 2017 Share Posted May 1, 2017 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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