Jump to content
Sign in to follow this  
MrJustinMeyer

COM OBJECT - Translating C# METHOD Ref to AU3

Recommended Posts

I noticed that you reassign "ERROR" to $rValue every iteration.  I think that "ERROR" is assigned and then this evaluates to False: If $ALL_OBJECTS.Current.Name() = "BEAM" Then.  This will overwrite $rValue.  Try moving $rValue out of the loop.

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

I noticed that you reassign "ERROR" to $rValue every iteration.  I think that "ERROR" is assigned and then this evaluates to False: If $ALL_OBJECTS.Current.Name() = "BEAM" Then.  This will overwrite $rValue.  Try moving $rValue out of the loop.

 

Moved the $R_VALUE outside the loop, also tried giving it an empty string (= "") and the result is whatever I define the variable to be. The method does not supply the the queried information.

Current code below, also attached all msgbox photos in order of appearance.

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

 $TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

Sleep(1000)

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

MsgBox(0, "", "Object Interface Name: " & ObjName($ALL_OBJECTS, 1) & @CRLF & _
        "Object Description:    " & ObjName($ALL_OBJECTS, 2) & @CRLF & _
        "Object ProgID:      " & ObjName($ALL_OBJECTS, 3) & @CRLF & _
        "File Associated with Object:         " & ObjName($ALL_OBJECTS, 4) & @CRLF & _
        "Object Module Name:     " & ObjName($ALL_OBJECTS, 5) & @CRLF & _
        "CLSID:     " & ObjName($ALL_OBJECTS, 6) & @CRLF & _
        "IID of Objects Interface:        " & ObjName($ALL_OBJECTS, 7))

$COUNT = 0
$DATA = "DATA:"
Global $R_VALUE = "ERROR" ;Defined to show change from method below
While $ALL_OBJECTS.MoveNext()

    If $ALL_OBJECTS.Current.Name() = "BEAM" Then ;Only Objects with BEAM name - Works

        $PROP_REPORT = $ALL_OBJECTS.Current.GetReportProperty("PROFILE", $R_VALUE)
        $DATA = $DATA & @CRLF & "PROFILE = " & $PROP_REPORT & " VALUE = " & $R_VALUE
        ;$PROP_REPORT returns true unless first string is not found, $R_VALUE is not modified
        ;$DATA result is PROFILE = TRUE and VALUE = ERROR

    EndIf

    $COUNT = $COUNT + 1

WEnd

MsgBox(0, "OBJECT COUNT", $COUNT)
MsgBox(0, "DATA", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

post-82359-0-31039100-1381435289_thumb.p

post-82359-0-93498000-1381435293_thumb.p

post-82359-0-99996300-1381435297_thumb.p

Share this post


Link to post
Share on other sites
#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

 $TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

Sleep(1000)

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

MsgBox(0, "", "Object Interface Name: " & ObjName($ALL_OBJECTS, 1) & @CRLF & _
        "Object Description:    " & ObjName($ALL_OBJECTS, 2) & @CRLF & _
        "Object ProgID:      " & ObjName($ALL_OBJECTS, 3) & @CRLF & _
        "File Associated with Object:         " & ObjName($ALL_OBJECTS, 4) & @CRLF & _
        "Object Module Name:     " & ObjName($ALL_OBJECTS, 5) & @CRLF & _
        "CLSID:     " & ObjName($ALL_OBJECTS, 6) & @CRLF & _
        "IID of Objects Interface:        " & ObjName($ALL_OBJECTS, 7))

$COUNT = 0
$DATA = "DATA:"

While $ALL_OBJECTS.MoveNext()

    Global $R_VALUE = "ERROR" ;Defined to show change from method below

    If $ALL_OBJECTS.Current.Name() = "BEAM" Then ;Only Objects with BEAM name - Works

        $PROP_REPORT = $ALL_OBJECTS.Current.GetReportProperty_2("PROFILE", $R_VALUE)
        $DATA = $DATA & @CRLF & "PROFILE = " & $PROP_REPORT & " VALUE = " & $R_VALUE
        ;$PROP_REPORT returns true unless first string is not found, $R_VALUE is not modified
        ;$DATA result is PROFILE = TRUE and VALUE = ERROR

    EndIf

    $COUNT = $COUNT + 1

WEnd

MsgBox(0, "OBJECT COUNT", $COUNT)
MsgBox(0, "DATA", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

Line 39 is:

If $ALL_OBJECTS.Current.Name() = "BEAM" Then

...That's not the line that you said that you have issues with.

Btw, "Name" is property, not method. Try without brackets.

Share this post


Link to post
Share on other sites

I am not sure where I may have caused the confusion, but the line I am having trouble with is;

$PROP_REPORT = $ALL_OBJECTS.Current.GetReportProperty("PROFILE", $R_VALUE)

To recap, the $R_VALUE is not getting the "PROFILE" from the current object.

I removed the brackets and the property is compared to the string "BEAM" as you said. Results are the same.

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

 $TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

Sleep(1000)

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

MsgBox(0, "", "Object Interface Name: " & ObjName($ALL_OBJECTS, 1) & @CRLF & _
        "Object Description:    " & ObjName($ALL_OBJECTS, 2) & @CRLF & _
        "Object ProgID:      " & ObjName($ALL_OBJECTS, 3) & @CRLF & _
        "File Associated with Object:         " & ObjName($ALL_OBJECTS, 4) & @CRLF & _
        "Object Module Name:     " & ObjName($ALL_OBJECTS, 5) & @CRLF & _
        "CLSID:     " & ObjName($ALL_OBJECTS, 6) & @CRLF & _
        "IID of Objects Interface:        " & ObjName($ALL_OBJECTS, 7))

$COUNT = 0
$DATA = "DATA:"
Global $R_VALUE = "ERROR" ;Defined to show change from method below
While $ALL_OBJECTS.MoveNext()

    If $ALL_OBJECTS.Current.Name = "BEAM" Then ;Only Objects with BEAM name - Works

        $PROP_REPORT = $ALL_OBJECTS.Current.GetReportProperty("PROFILE", $R_VALUE)
        $DATA = $DATA & @CRLF & "PROFILE = " & $PROP_REPORT & " VALUE = " & $R_VALUE
        ;$PROP_REPORT returns true unless first string is not found, $R_VALUE is not modified
        ;$DATA result is PROFILE = TRUE and VALUE = ERROR

    EndIf

    $COUNT = $COUNT + 1

WEnd

MsgBox(0, "OBJECT COUNT", $COUNT)
MsgBox(0, "DATA", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

Share this post


Link to post
Share on other sites

A few interesting developments, yet no solution.

I have made some changes to the code, the primary one being;

Attempting to retrieve "CHECKED_BY" via "GetUserProperty" vs "PROFILE" via "GetReportProperty" for two reasons, (1) I am trying to stick to the example I have in C# (First Post) and, (2) I was able to retrieve "PROFILE" another way (though that was not goal, I need to be able to get specified report poroperties), see code.

What I find very interesting is that $PROP_REPORT returns "True" only if a the "CHECKED_BY" property of a member in the model has been set, otherwise it is "False". See results below.

Unfortunately the $CBY variable is still not updated (with who it was checked by) by the method. FYI this was $R_VALUE in previous posts.

Code;

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

$COUNT = 0
$DATA = "NAME = BEAM:" & @CRLF

While $ALL_OBJECTS.MoveNext

    $CURRENT = $ALL_OBJECTS.Current
    Global $CBY = "*"

    If $CURRENT.Name = "BEAM" Then

        $PROFILE = $CURRENT.Profile.ProfileString
        $ID = $CURRENT.Identifier.ToString
        $GUID = $TSMm.GetGUIDByIdentifier($CURRENT.Identifier)

        $PROP_REPORT = $CURRENT.GetUserProperty("CHECKED_BY", $CBY)
        $DATA = $DATA & @CRLF & "GUID=" & $GUID & @CRLF & " PROP_REPORT=" & $PROP_REPORT & " CHECKED_BY=" & $CBY
        $DATA = $DATA & @CRLF & " PROFILE=" & $PROFILE

    EndIf

    $COUNT = $COUNT + 1

WEnd

ClipPut($DATA)
MsgBox(0, $COUNT & " OBJECTS", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

Results;

NAME = BEAM:

GUID=ID5252F41B-0000-41C4-3133-383131363833
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X58
GUID=ID524D5D86-000A-EF17-3133-383038313836
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000A-EF13-3133-383038313836
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524C72CC-0000-0004-3133-383037343138
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0000-0004-3133-383038303139
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000A-EF71-3133-383038313839
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000C-AB8D-3133-383038323031
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-EB28-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-EB20-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0002-3B01-3133-383038303838
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0006-B239-3133-383038313137
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0002-3AFD-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0002-3B09-3133-383038303838
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000A-EF5F-3133-383038313838
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-AB89-3133-383038323031
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0006-7280-3133-383038313135
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0002-3B05-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000A-EF85-3133-383038313839
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0000-3F8B-3133-383038303230
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0006-7283-3133-383038313136
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0006-B23D-3133-383038313137
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000C-EB24-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID5253F579-0000-00E0-3133-383132333436
 PROP_REPORT=False CHECKED_BY=*
 PROFILE=W16X40

Share this post


Link to post
Share on other sites

I am not sure where I may have caused the confusion

That's very simple to answer, you posted the wrong code. I asked of you to post the code that caused the error and you posted some other code which would cause error to be displayed on another line. Don't do that if you want serious help.

So, if you don't mind, could you run this exact code and post the error you get:

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

$COUNT = 0
$DATA = "NAME = BEAM:" & @CRLF

While $ALL_OBJECTS.MoveNext

    $CURRENT = $ALL_OBJECTS.Current
    Global $CBY = "*"

    If $CURRENT.Name = "BEAM" Then

        $PROFILE = $CURRENT.Profile.ProfileString
        $ID = $CURRENT.Identifier.ToString
        $GUID = $TSMm.GetGUIDByIdentifier($CURRENT.Identifier)

        $PROP_REPORT = $CURRENT.GetUserProperty_2("CHECKED_BY", $CBY)
        $DATA = $DATA & @CRLF & "GUID=" & $GUID & @CRLF & " PROP_REPORT=" & $PROP_REPORT & " CHECKED_BY=" & $CBY
        $DATA = $DATA & @CRLF & " PROFILE=" & $PROFILE

    EndIf

    $COUNT = $COUNT + 1

WEnd

ClipPut($DATA)
MsgBox(0, $COUNT & " OBJECTS", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

Share this post


Link to post
Share on other sites

That's very simple to answer, you posted the wrong code. I asked of you to post the code that caused the error and you posted some other code which would cause error to be displayed on another line. Don't do that if you want serious help.

So, if you don't mind, could you run this exact code and post the error you get:

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

$COUNT = 0
$DATA = "NAME = BEAM:" & @CRLF

While $ALL_OBJECTS.MoveNext

    $CURRENT = $ALL_OBJECTS.Current
    Global $CBY = "*"

    If $CURRENT.Name = "BEAM" Then

        $PROFILE = $CURRENT.Profile.ProfileString
        $ID = $CURRENT.Identifier.ToString
        $GUID = $TSMm.GetGUIDByIdentifier($CURRENT.Identifier)

        $PROP_REPORT = $CURRENT.GetUserProperty_2("CHECKED_BY", $CBY)
        $DATA = $DATA & @CRLF & "GUID=" & $GUID & @CRLF & " PROP_REPORT=" & $PROP_REPORT & " CHECKED_BY=" & $CBY
        $DATA = $DATA & @CRLF & " PROFILE=" & $PROFILE

    EndIf

    $COUNT = $COUNT + 1

WEnd

ClipPut($DATA)
MsgBox(0, $COUNT & " OBJECTS", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

 

The attached image below is the error of the code your quoting.

I understand that you are very involved (and likely busy) so, not only do I want yours and others "serious help", I truly appreciate it. I am trying to come up with a solution myself along with the help of others. I can not and will not just wait for someone else to tell me how to do it. The code will likely change, hourly, but most importantly the question will remain the same until the thread is answered.

post-82359-0-06847400-1381631500_thumb.p

Share this post


Link to post
Share on other sites

Ok thanks. Now run this and post the error and the result:

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

$COUNT = 0
$DATA = "NAME = BEAM:" & @CRLF

While $ALL_OBJECTS.MoveNext

    $CURRENT = $ALL_OBJECTS.Current
    Global $CBY = "*"

    If $CURRENT.Name = "BEAM" Then

        $PROFILE = $CURRENT.Profile.ProfileString
        $ID = $CURRENT.Identifier.ToString
        $GUID = $TSMm.GetGUIDByIdentifier($CURRENT.Identifier)
    $CURRENT.SetUserProperty("CHECKED_BY", "Something")
        $PROP_REPORT = $CURRENT.GetUserProperty("CHECKED_BY", $CBY)
        $DATA = $DATA & @CRLF & "GUID=" & $GUID & @CRLF & " PROP_REPORT=" & $PROP_REPORT & " CHECKED_BY=" & $CBY
        $DATA = $DATA & @CRLF & " PROFILE=" & $PROFILE

    EndIf

    $COUNT = $COUNT + 1

WEnd

ClipPut($DATA)
MsgBox(0, $COUNT & " OBJECTS", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

Share this post


Link to post
Share on other sites

Ok thanks. Now run this and post the error and the result:

#AutoIt3Wrapper_UseX64=n

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$TSMm = ObjCreate("Tekla.Structures.Model.Model")
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "Could not connect to Tekla, verify and rerun")
    Exit
EndIf

If Not $TSMm.GetConnectionStatus() = "True" Then
    MsgBox(0, "Error", "Tekla Connection Failure")
    Exit
EndIf

$ALL_OBJECTS = $TSMm.GetModelObjectSelector().GetAllObjectsWithType(1) ;TYPE 1 = BEAM MODELOBJECTCLASS
If @error Then
    MsgBox(1,"ERROR", "Tekla.Structures.Model.Model" & @CRLF & "ObjectSelector")
    Exit
EndIf

$COUNT = 0
$DATA = "NAME = BEAM:" & @CRLF

While $ALL_OBJECTS.MoveNext

    $CURRENT = $ALL_OBJECTS.Current
    Global $CBY = "*"

    If $CURRENT.Name = "BEAM" Then

        $PROFILE = $CURRENT.Profile.ProfileString
        $ID = $CURRENT.Identifier.ToString
        $GUID = $TSMm.GetGUIDByIdentifier($CURRENT.Identifier)
    $CURRENT.SetUserProperty("CHECKED_BY", "Something")
        $PROP_REPORT = $CURRENT.GetUserProperty("CHECKED_BY", $CBY)
        $DATA = $DATA & @CRLF & "GUID=" & $GUID & @CRLF & " PROP_REPORT=" & $PROP_REPORT & " CHECKED_BY=" & $CBY
        $DATA = $DATA & @CRLF & " PROFILE=" & $PROFILE

    EndIf

    $COUNT = $COUNT + 1

WEnd

ClipPut($DATA)
MsgBox(0, $COUNT & " OBJECTS", $DATA)

Func _ErrFunc($oError)
    msgBox(0, "COM Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

 

No errors, results from $DATA below.

NAME = BEAM:

GUID=ID5253F579-0000-00E0-3133-383132333436
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-EB24-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0006-B23D-3133-383038313137
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0006-7283-3133-383038313136
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0000-3F8B-3133-383038303230
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000A-EF85-3133-383038313839
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0002-3B05-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0006-7280-3133-383038313135
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-AB89-3133-383038323031
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000A-EF5F-3133-383038313838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0002-3B09-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0002-3AFD-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0006-B239-3133-383038313137
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-0002-3B01-3133-383038303838
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-EB20-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000C-EB28-3133-383038323032
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000C-AB8D-3133-383038323031
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524D5D86-000A-EF71-3133-383038313839
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-0000-0004-3133-383038303139
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID524C72CC-0000-0004-3133-383037343138
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000A-EF13-3133-383038313836
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X40
GUID=ID524D5D86-000A-EF17-3133-383038313836
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W16X40
GUID=ID5252F41B-0000-41C4-3133-383131363833
 PROP_REPORT=True CHECKED_BY=*
 PROFILE=W12X58

Share this post


Link to post
Share on other sites

You are trying with latest beta AutoIt, right? You should if you aren't.

If you are using beta AutoIt and it still doesn't work then download version 3.3.9.12 (or older) from here, uninstall current beta and then try with that one.

3.3.9.13 was apparently version with mentioned bad changes. It's not like I don't trust Jon for correctly reverting the changes he did on my code, it's only that I trust him less after he has chosen to make the changes.

Share this post


Link to post
Share on other sites

You are trying with latest beta AutoIt, right? You should if you aren't.

If you are using beta AutoIt and it still doesn't work then download version 3.3.9.12 (or older) from here, uninstall current beta and then try with that one.

3.3.9.13 was apparently version with mentioned bad changes. It's not like I don't trust Jon for correctly reverting the changes he did on my code, it's only that I trust him less after he has chosen to make the changes.

 

I am using the latest beta.

I typically do not use an installed version, and just run from my flash drive. But through this ordeal I have tried the installed version, the installed beta, and now 3.3.9.12 version as well.

Share this post


Link to post
Share on other sites

Is there any possibility that I get in touch with that objects myself? Do I need to pay thousands of dollars and have or work for multi-million dollar business or is there anything available for developers?

Btw, yesterday you posted at 04:44 AM and today at 03:33 AM according to my forum time. That's cool :D.

If you post tomorrow at 02:22 AM then what will happen when you hit zeroes? Will the world we know cease to exist? Should we get drunk or something before that? Damn Tekla :cry:

Share this post


Link to post
Share on other sites

 

Is there any possibility that I get in touch with that objects myself?

 

That is questionable...

 

Do I need to pay thousands of dollars and have or work for multi-million dollar business

 

It helps...

 

or is there anything available for developers?

 

If you pay thousands of dollars and have or work for multi-million dollar business...

The API and its documentation are extremely well maintained, and their is a great developer network. Unfortunately you have to be a member of the very expensive "maintenance" club to get access. And even then, if you don't follow the way of C#, no support.

Share this post


Link to post
Share on other sites

Hi

Sorry to dig up an old thread....well its not old old, but it's old enough. But from what I can tell there is not a lot of *new* info on this topic. I am not a developer by any means, but I do come across some interesting finds on the web from time to time.

This may or may not be appropriate for this subject, but I see that it was causing some grief.

Could this be a solution or even of interest to anyone here?

 Get AutoIt reference working in C# http://stackoverflow.com/questions/14644258/get-autoit-reference-working-in-c-sharp

Solution based off this here -> How to use a 32 bit COM object on Windows Server 2008 (works on 2008 R2 but non 2008) http://stackoverflow.com/questions/4043954/how-to-use-a-32-bit-com-object-on-windows-server-2008-works-on-2008-r2-but-non
 

Edit: For the sake of broken links and lost content here:
 

 

Okay the solution was:

  1. Open up regedit*32 (c:windowssyswow64regedit)
  2. Search for AutoItX in HKEY_CLASSES_ROOTAppID
  3. I found it in HKEY_CLASSES_ROOTAppID{6E8109C4-F369-415D-AF9A-2AEEFF313234}
  4. Create a blank REG_SZ (String) entry called DllSurrogate

For some reason, this completely solved the issue.

 

If so then a minor update to the AutoIT installation could be a solution?

Edited by DigitalFacade82

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
Sign in to follow this  

  • Similar Content

    • By Bilgus
      Trying to figure out how to do CallByName on AutoIt COM objects due to the lack of being able to set properties within an Execute() statement
      Several Ideas were Tried https://www.autoitscript.com/forum/topic/200129-set-object-properties-with-propertyname-and-value-taken-from-an-array/
      I think this is the best; Patching the vtable of IDispatch so we can intercept a Fake function call ($obj.Au3_CallByName)
      use it like this
      Local $oDictionary = ObjCreate("Scripting.Dictionary") ; EXAMPLE Au3_CallByname_Init() ; (you can optionally provide a classname here but we patch the main Idispatch interface so really no need) $Au3_CallByName = "Add" ; Method we want to call $oDictionary.Au3_CallByName("Test", "Value") Au3_CallByname_Init(False) ; (Not Strictly Needed unhooked on exit) NOTE:  Au3_CallByname_Init() doesn't have to be called at the top of the script, just call it before you need to call by name...
      Code + Example
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Au3CallByName, Bilgus Global $Au3_CallByName = 0 Local $hKernel32 = DllOpen("Kernel32.dll") OnAutoItExitRegister(__CallByNameCleanup) Func __CallByNameCleanup() Au3_CallByName_Init(False) ;Unload DllClose($hKernel32) EndFunc ;==>__CallByNameCleanup ; Takes a pointer to the v-table in a class and replaces specified member Id in it to a new one. Func __HookVTableEntry($pVtable, $iVtableOffset, $pHook, ByRef $pOldRet) ;;https://www.autoitscript.com/forum/topic/107678-hooking-into-the-idispatch-interface/ Local Const $PAGE_READWRITE = 0x04 Local $tpVtable = DllStructCreate("ptr", $pVtable) Local $szPtr = DllStructGetSize($tpVtable) Local $pFirstEntry, $pEntry, $tEntry, $aCall, $flOldProtect, $bStatus ; Dereference the vtable pointer $pFirstEntry = DllStructGetData($tpVtable, 1) $pEntry = $pFirstEntry + ($iVtableOffset * $szPtr) ; Make the memory free for all. Yay! $aCall = DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $PAGE_READWRITE, "dword*", 0) If @error Or Not $aCall[0] Then ConsoleWriteError("Error: Failed To hook vTable" & @CRLF) Return False EndIf $flOldProtect = $aCall[4] $tEntry = DllStructCreate("ptr", $pEntry) $pOldRet = DllStructGetData($tEntry, 1) If $pOldRet <> $pHook Then DllStructSetData($tEntry, 1, $pHook) $bStatus = True Else ;Already Hooked ConsoleWriteError("Error: vTable is already hooked" & @CRLF) $bStatus = False EndIf ;put the memory protect back how we found it DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $flOldProtect, "dword*", 0) Return $bStatus EndFunc ;==>__HookVTableEntry ; Everytime autoit wants to call a method, get or set a property in a object it needs to go to ; IDispatch::GetIDsFromNames. This is our version of that function, note that by defining this ourselves ; we can fool autoit to believe that the object supports a lot of different properties/methods. Func __IDispatch_GetIDsFromNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local Const $CSTR_EQUAL = 0x02 Local Const $LOCALE_SYSTEM_DEFAULT = 0x800 Local Const $DISP_E_UNKNOWNNAME = 0x80020006 Local Static $pGIFN = __Pointer_GetIDsFromNames() Local Static $tpMember = DllStructCreate("ptr") If $Au3_CallByName Then Local $hRes, $aCall, $tMember ;autoit only asks for one member $aCall = DllCall($hKernel32, 'int', 'CompareStringW', 'dword', $LOCALE_SYSTEM_DEFAULT, 'dword', 0, 'wstr', "Au3_CallByName", 'int', -1, _ 'struct*', DllStructGetData(DllStructCreate("ptr[" & $cNames & "]", $rgszNames), 1, 1), 'int', -1) If Not @error And $aCall[0] = $CSTR_EQUAL Then ;ConsoleWrite("CallByName: " & $Au3_CallByName & @CRLF) $tMember = DllStructCreate("wchar[" & StringLen($Au3_CallByName) + 1 & "]") DllStructSetData($tMember, 1, $Au3_CallByName) DllStructSetData($tpMember, 1, DllStructGetPtr($tMember)) $rgszNames = $tpMember $Au3_CallByName = 0 EndIf EndIf ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWrite("Error: GetIDsFromNames: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf Return $hRes[0] EndFunc ;==>__IDispatch_GetIDsFromNames Func __Pointer_GetIDsFromNames($ptr = 0) Local Static $pOldGIFN = $ptr If $ptr <> 0 Then $pOldGIFN = $ptr Return $pOldGIFN EndFunc ;==>__Pointer_GetIDsFromNames Func Au3_CallByName_Init($bHook = True, $classname = "shell.application") Local Const $iOffset_GetIDsFromNames = 5 Local Static $IDispatch_GetIDsFromNames_Callback = 0 Local $oObject, $pObject, $pHook, $pOldGIFN If $bHook Then If $IDispatch_GetIDsFromNames_Callback = 0 Then $IDispatch_GetIDsFromNames_Callback = DllCallbackRegister("__IDispatch_GetIDsFromNames", "LRESULT", "ptr;ptr;ptr;dword;dword;ptr") EndIf $pHook = DllCallbackGetPtr($IDispatch_GetIDsFromNames_Callback) Else $pHook = __Pointer_GetIDsFromNames() If $pHook <= 0 Then Return ;Already Unloaded EndIf $oObject = ObjCreate($classname) $pObject = DllStructSetData(DllStructCreate("ptr"), 1, $oObject) If __HookVTableEntry($pObject, $iOffset_GetIDsFromNames, $pHook, $pOldGIFN) Then __Pointer_GetIDsFromNames($pOldGIFN) ;Save the original pointer to GetIDsFromNames If Not $bHook Then DllCallbackFree($IDispatch_GetIDsFromNames_Callback) $IDispatch_GetIDsFromNames_Callback = 0 EndIf Else ;Error EndIf $oObject = 0 EndFunc ;==>Au3_CallByName_Init ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;TESTS; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Au3_CallByName_Init() #include <ie.au3> Global $oRegistrationInfo = _IECreate() Global $aRegistrationInfo[] = ['Left=10', 'Top= 10', 'Width=450', 'Height=600'] Global $oObject = $oRegistrationInfo Local $oDictionary = ObjCreate("Scripting.Dictionary") Local $oDictionary2 = ObjCreate("Scripting.Dictionary") ;Au3_CallByName_Init($oObject) __TS_TaskPropertiesSet($oObject, $aRegistrationInfo) MsgBox(0, "Info", "Press OK to exit") $oRegistrationInfo.quit $oRegistrationInfo = 0 $oObject = 0 Sleep(1000) For $i = 1 To 10 $Au3_CallByName = "Add" $oDictionary.Au3_CallByName("test1:" & $i, "Dictionary Item: " & $i) Next $Au3_CallByName = "keys" For $sKey In $oDictionary.Au3_CallByName() For $j = 0 To 1 $Au3_CallByName = ($j = 0) ? "Item" : "Exists" ConsoleWrite($sKey & " -> " & $oDictionary.Au3_CallByName($sKey) & @CRLF) Next Next Au3_CallByName_Init(False) ;Unload Au3_CallByName_Init() Local $aRegistrationInfo[] = ['Left=1000', 'Width=450'] ConsoleWrite(@CRLF & "NEW IE" & @CRLF & @CRLF) $oRegistrationInfo = _IECreate() __TS_TaskPropertiesSet($oRegistrationInfo, $aRegistrationInfo) MsgBox(0, "Info", "Press OK to exit") $oRegistrationInfo.quit For $i = 1 To 10 $Au3_CallByName = "Add" $oDictionary2.Au3_CallByName("test2:" & $i, "Dictionary Item: " & $i) Next $Au3_CallByName = "keys" For $sKey In $oDictionary2.Au3_CallByName() For $j = 0 To 1 $Au3_CallByName = ($j = 0) ? "Item" : "Exists" ConsoleWrite($sKey & " -> " & $oDictionary2.Au3_CallByName($sKey) & @CRLF) Next Next Au3_CallByName_Init(False) ;Unload (Not Strictly Needed, Done on Script Close) Func __TS_TaskPropertiesSet(ByRef $oObject, $aProperties) Local $aTemp If IsArray($aProperties) Then For $i = 0 To UBound($aProperties) - 1 $aTemp = StringSplit($aProperties[$i], "=", 2) ; 2 -> $STR_NOCOUNT) If @error Then ContinueLoop ConsoleWrite("Command: $oObject." & $aTemp[0] & " = " & $aTemp[1] & @CRLF) $Au3_CallByName = $aTemp[0] $oObject.Au3_CallByName = $aTemp[1] ConsoleWrite("Result : " & Hex(@error) & @CRLF) ; If @error Then Return SetError(1, @error, 0) Next EndIf EndFunc ;==>__TS_TaskPropertiesSet  
    • By mLipok
      Today, in the end as well, worked out using the Acrobat Reader ActiveX COM Object "AcroPDF.PDF.1"
      #include-once #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <MenuConstants.au3> #include <WinAPI.au3> ;~ Thanks to BrewManNH ;~ http://www.autoitscript.com/forum/topic/134878-guiregistermsg-replacement-for-guictrlsetonevent-and-guigetmsg/ ;~ Thanks to mikell ;~ http://www.autoitscript.com/forum/topic/161985-how-to-close-gui-with-guiregistermsg/ ; Install a custom error handler Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc") Global $__hExampleGUI Global $__idOPEN Global $_fExit Global $__hACROBAT_GUI = '' Global $__idACROBAT_GUI_CTRL_AX = '' Global $__oACROBAT_READER = '' #include <GUIConstantsEx.au3> ;~ GUIRegisterMsg($WM_ERASEBKGND, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_PAINT, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_ACTIVATE, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_CAPTURECHANGED, "_WM_EXTRACTOR") ;~ GUIRegisterMsg($WM_DEVICECHANGE, "_WM_EXTRACTOR") GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXTRACTOR") GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR") _ExampleProgram_Gui() While 1 Sleep(10) If $_fExit Then _ACROBAT_GUI_DELETE() DeleteGui() Exit EndIf WEnd Func DeleteGui() GUIDelete($__hExampleGUI) EndFunc ;==>DeleteGui Func _ExampleProgram_Gui() ; Create a GUI with various controls. $__hExampleGUI = GUICreate("Example") $__idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $__hExampleGUI) EndFunc ;==>_ExampleProgram_Gui #Region ACROBAT FUNCTION Func _AcrobatInit() $__oACROBAT_READER = ObjCreate("AcroPDF.PDF.1"); Return $__oACROBAT_READER.GetVersions EndFunc ;==>_AcrobatInit Func _Acrobat_Events(ByRef $aMSG) If $aMSG[1] = $__hACROBAT_GUI Then Switch $aMSG[0] Case $GUI_EVENT_CLOSE _ACROBAT_GUI_DELETE() EndSwitch EndIf EndFunc ;==>_Acrobat_Events Func _ACROBAT_Destroy() $__oACROBAT_READER = "" ;~ MsgBox(1,'test','destroyed') EndFunc ;==>_ACROBAT_Destroy Func _AcrobatShow($sFile, $sTitle = "PDF ", $iLeft = 50, $iTop = 0, $iWidth = 1000, $iHeight = 700) If FileExists($sFile) Then _AcrobatInit() ; Set option $__oACROBAT_READER.src = $sFile $__oACROBAT_READER.SetLayoutMode(4) $__oACROBAT_READER.SetPageMode(1) $__oACROBAT_READER.SetShowToolbar(0) $__oACROBAT_READER.SetView(1) ; Create GUI $__hACROBAT_GUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iWidth - 20, $iHeight - 10) GUICtrlSetStyle($__idACROBAT_GUI_CTRL_AX, $WS_VISIBLE) GUISetState() EndIf EndFunc ;==>_AcrobatShow Func _ACROBAT_Refresh() If IsObj($__oACROBAT_READER) Then Local $hPreviouslyGui = GUISwitch($__hACROBAT_GUI) GUISetState(@SW_LOCK) Local $iGUI_PDFWidth = WinGetPos($__hACROBAT_GUI)[2] - 20 Local $iGUI_PDFHeight = WinGetPos($__hACROBAT_GUI)[3] - 40 Local $sFile = $__oACROBAT_READER.src ; this below line do not works with Acro Reader ; Local $iCurrentPage = $__oACROBAT_READER.GetNumber Local $iCurrentPage = 0 _ACROBAT_Destroy() GUICtrlDelete($__idACROBAT_GUI_CTRL_AX) _AcrobatInit() $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iGUI_PDFWidth, $iGUI_PDFHeight) $__oACROBAT_READER.src = $sFile ;~ $__oACROBAT_READER.SetCurrentPage($iCurrentPage) GUISetState(@SW_UNLOCK) GUISwitch($hPreviouslyGui) EndIf EndFunc ;==>_ACROBAT_Refresh Func _ACROBAT_GUI_DELETE() _ACROBAT_Destroy() if IsHWnd($__hACROBAT_GUI) then GUIDelete($__hACROBAT_GUI) EndFunc ;==>_ACROBAT_GUI_DELETE #EndRegion ACROBAT FUNCTION #Region MSG and ERROR HANDLER Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam) ;~ ConsoleWrite('! $hWnd = ' & $hWnd & ' $iMsg = ' & $iMsg & '('&HEX($iMsg)&')'& ' $wParam = ' & $wParam & ' $lParam = ' & $lParam & @CRLF) If $hWnd = ControlGetHandle($__hACROBAT_GUI, '', $__idACROBAT_GUI_CTRL_AX) Then ConsoleWrite('! -------------- $hWnd = ' & $hWnd & ' $iMsg = ' & $iMsg & '(' & Hex($iMsg) & ')' & ' $wParam = ' & $wParam & ' $lParam = ' & $lParam & @CRLF) EndIf If $hWnd = $__hACROBAT_GUI Then Switch $iMsg Case $WM_COMMAND #cs Case $WM_ACTIVATE Local $test = BitAND($wParam, 0x00000004) if $test <> 0 then MsgBox(1,'$WM_ACTIVATE','test') _ACROBAT_Refresh() EndIf Case $WM_ERASEBKGND WinGetHandle("[ACTIVE]") if $__hACROBAT_GUI <> _WinAPI_GetWindow ( $__hACROBAT_GUI, $GW_HWNDPREV ) then ConsoleWrite('! Case $WM_ERASEBKGND' & @CRLF) _ACROBAT_Refresh() _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE) EndIf Case $WM_PAINT _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE) Case $WM_CAPTURECHANGED _ACROBAT_Refresh() Case $WM_DEVICECHANGE _ACROBAT_Refresh() #ce Case $WM_EXITSIZEMOVE _ACROBAT_Refresh() Case $WM_SYSCOMMAND ;~ Local $test = BitAND($wParam, 0xFFF0) Local $test = BitAND($wParam, 0x0000FFFF) Switch $test Case $SC_CLOSE _ACROBAT_GUI_DELETE() Case $SC_CONTEXTHELP Case $SC_DEFAULT Case $SC_HOTKEY Case $SC_HSCROLL Case $SC_KEYMENU Case $SC_MAXIMIZE _ACROBAT_Refresh() Case $SC_MINIMIZE Case $SC_MONITORPOWER Case $SC_MOUSEMENU Case $SC_MOVE ;~ _ACROBAT_Refresh() Case $SC_NEXTWINDOW ;~ _ACROBAT_Refresh() Case $SC_PREVWINDOW ;~ _ACROBAT_Refresh() Case $SC_RESTORE _ACROBAT_Refresh() Case $SC_SCREENSAVE Case $SC_SIZE Case $SC_TASKLIST Case $SC_VSCROLL EndSwitch EndSwitch EndIf If $hWnd = $__hExampleGUI Then Switch $iMsg Case $WM_COMMAND Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Switch $nID Case $__idOPEN if not IsObj($__oACROBAT_READER) then _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here) EndIf EndSwitch Case $WM_SYSCOMMAND Local $test = BitAND($wParam, 0xFFF0) Switch $test Case $SC_CLOSE $_fExit = True Case $SC_CONTEXTHELP Case $SC_DEFAULT Case $SC_HOTKEY Case $SC_HSCROLL Case $SC_KEYMENU Case $SC_MAXIMIZE Case $SC_MINIMIZE Case $SC_MONITORPOWER Case $SC_MOUSEMENU Case $SC_MOVE Case $SC_NEXTWINDOW Case $SC_PREVWINDOW Case $SC_RESTORE Case $SC_SCREENSAVE Case $SC_SIZE Case $SC_TASKLIST Case $SC_VSCROLL EndSwitch EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_EXTRACTOR Func _ComErrFunc() Local $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "AutoItCOM Test", _ "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) EndFunc ;==>_ComErrFunc #EndRegion MSG and ERROR HANDLER Any comments are welcome.
      Cheers
      mLipok
    • By rcmaehl
      Hi all, 

      Recently my work swapped from Cisco CTIOS to Finesse. This completely threw me off as I had been automating the Win32 application and I had never done IUIAutomation before. As such I've been messing around with the API and will be adding code as I figure it out. While I do have Supervisor access, I will likely not be adding functions for those features yet.
      Currently Available Functions:
      User API - Query and Set User Info
      Dialog API - Query and Set Call and other Dialog Info
      Queue API - Query Assigned Queues
      Team API - Query Users in a Team


      Changelog:
       
      Download:
       
    • By jantograaf
      Hi all,
      I'm trying to write a script that connects with a VBA/COM API to get the status of a connected phone. I've been looking up and down this forum for tips or other user's experiences, but I can't seem to find anything (even remotely) similar. It shouldn't be so hard to do, however.
      Software I'm trying to connect to
      I'm trying to integrate CallCenter by using their API, which is documented over here : JustRemotePhone API Reference
      Things I've tried
      I've tried using ObjCreate but I don't get any result, it always returns the same (negative) error.
      #Version 1 tried ObjCreate("JustRemotePhone.RemotePhoneService") #Version 2 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService") #Version 3 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService.Application") None of the three versions I tried seem to deliver any result other than a negative error value which basically says that the given class is not valid.
      I am starting to get the hang of AutoIt by now, but unmanaged programming languages and object-oriented stuff is still quite a grey zone for me. If anyone could help me 'talk' to this application, I'd be immensely grateful!
      Thanks in advance and kind regards from Belgium!
       
      Jan
    • By Rhidlor
      So I'm trying to do some as400 automation and hit a wall when trying to get a COM object. The code on line 8 is failing, the as400.ws file opens with PCSWS.exe so I tried using that as the file path too but that didn't work either. Any and all help is greatly appreciated! 
       
      $file = "C:\Users\Rhidlor\Desktop\as400.ws" If Not FileExists($file) Then MsgBox(0, "Error", "Error finding file") Exit EndIf $object = ObjGet($file) If @error Then MsgBox(0, "Error", "Error getting object") Exit EndIf $object.SendKeys("05")  
×
×
  • Create New...