Jump to content

Recommended Posts

Posted

Hi,

My AutoIt script is as folllows:

;use for calling function add2NosA in dll
;Local $vNo1 = 33
;Local $vNo2 = 11

;use for calling function sortNos in dll
Local $vNo1 = [11,7,9]
Local $vNo2 = [1,3,2]

; _ArrayDisplay($vNo1, "vNo1 display")
; _ArrayDisplay($vNo2, "vNo2 display")

;Local $hWnd = DllOpen("E:\CV-Dell-1\autoit3\myComObj1.dll")
Local $hWnd = ObjCreate("myComObj1.clsMath")

if (@error) Then
   MsgBox (0, "Error", "Error1 = " & @error)
   Exit
EndIf

;function call method - DllCall with function name
;Local $aRes = DllCall($hWnd, "int", "addNosA", "int", $vNo1, "int", $vNo2)
;Local $aRes = DllCall($hWnd, "Ptr", "sortNos", "Array", $vNo1, "Array", $vNo2)

;function call method - $hWnd.<function name>
;Local $aRes = $hWnd.add2NosA($vNo1, $vNo2)     ; this works fine with ObjCreate
Local $aRes = $hWnd.sortNos($vNo1, $vNo2)


if (@error) Then
   MsgBox (0, "Error", "Error2 = " & @error)
   DllClose($hWnd)
   Exit
EndIf

;use appropriate msgbox
;MsgBox(0,"Result", "Result = " & $vNo1[0])
MsgBox(0,"Result", "Result = " & $aRes)
 _ArrayDisplay($vNo1, "vNo1 display")
 _ArrayDisplay($aRes , "aRes display")

DllClose($hWnd)

My VB.Net - ClassLibrary - Dll - COM obj is as follows - has 2 functions - add2NosA and sortNos:

<ComClass(clsMath.ClassId, clsMath.InterfaceId, clsMath.EventsId)>
Public Class clsMath

    Public Const ClassId As String = "3A42F85E-24C8-4BAA-91B5-AE56C4683C13"
    Public Const InterfaceId As String = "D99D7C79-2BA7-4A33-B7BC-9B7F19FDF828"
    Public Const EventsId As String = "CA128AC4-580C-4112-9EAD-8D1599E3F37A"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Function add2NosA(ByVal no1 As Integer, ByVal no2 As Integer) As Integer
        Return (no1 + no2)
    End Function
    Public Sub sortNos(ByRef no1 As Array, ByRef no2 As Array)

        Array.Sort(no1)
        no2 = no1


    End Sub
End Class

 Over all I tried various 8 options mentioned in the attached Excel file - with only 1 combination working.

Overall could not make Array returned capture in AutoIt script. 

Can someone help please?

Thanks in  advance.

Options-Tried-Matrix-Results.xlsx

Posted
Posted
On 2/17/2020 at 10:40 PM, LarsJ said:

The easiest way to use C# and VB.NET code in AutoIt is to use the techniques demonstrated in this example.

Thanks LarsJ, It worked. 

Truly appreciate this. Also more so since this was not in the FULL version downloaded and also showed me the example. 

On 2/17/2020 at 1:49 PM, IndianSage said:

Hi,

My AutoIt script is as folllows:

;use for calling function add2NosA in dll
;Local $vNo1 = 33
;Local $vNo2 = 11

;use for calling function sortNos in dll
Local $vNo1 = [11,7,9]
Local $vNo2 = [1,3,2]

; _ArrayDisplay($vNo1, "vNo1 display")
; _ArrayDisplay($vNo2, "vNo2 display")

;Local $hWnd = DllOpen("E:\CV-Dell-1\autoit3\myComObj1.dll")
Local $hWnd = ObjCreate("myComObj1.clsMath")

if (@error) Then
   MsgBox (0, "Error", "Error1 = " & @error)
   Exit
EndIf

;function call method - DllCall with function name
;Local $aRes = DllCall($hWnd, "int", "addNosA", "int", $vNo1, "int", $vNo2)
;Local $aRes = DllCall($hWnd, "Ptr", "sortNos", "Array", $vNo1, "Array", $vNo2)

;function call method - $hWnd.<function name>
;Local $aRes = $hWnd.add2NosA($vNo1, $vNo2)     ; this works fine with ObjCreate
Local $aRes = $hWnd.sortNos($vNo1, $vNo2)


if (@error) Then
   MsgBox (0, "Error", "Error2 = " & @error)
   DllClose($hWnd)
   Exit
EndIf

;use appropriate msgbox
;MsgBox(0,"Result", "Result = " & $vNo1[0])
MsgBox(0,"Result", "Result = " & $aRes)
 _ArrayDisplay($vNo1, "vNo1 display")
 _ArrayDisplay($aRes , "aRes display")

DllClose($hWnd)

My VB.Net - ClassLibrary - Dll - COM obj is as follows - has 2 functions - add2NosA and sortNos:


<ComClass(clsMath.ClassId, clsMath.InterfaceId, clsMath.EventsId)>
Public Class clsMath

    Public Const ClassId As String = "3A42F85E-24C8-4BAA-91B5-AE56C4683C13"
    Public Const InterfaceId As String = "D99D7C79-2BA7-4A33-B7BC-9B7F19FDF828"
    Public Const EventsId As String = "CA128AC4-580C-4112-9EAD-8D1599E3F37A"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Function add2NosA(ByVal no1 As Integer, ByVal no2 As Integer) As Integer
        Return (no1 + no2)
    End Function
    Public Sub sortNos(ByRef no1 As Array, ByRef no2 As Array)

        Array.Sort(no1)
        no2 = no1


    End Sub
End Class

 Over all I tried various 8 options mentioned in the attached Excel file - with only 1 combination working.

Overall could not make Array returned capture in AutoIt script. 

Can someone help please?

Thanks in  advance.

Options-Tried-Matrix-Results.xlsx 9.75 kB · 2 downloads

 

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
×
×
  • Create New...