Jump to content

Recommended Posts

  • 3 months later...
  • 9 months later...
Posted

I was playing with default method of an object but I have a situation and I not sure what is wrong. What I am missing?

#include-once
#include <AutoItObject.au3>

_AutoItObject_Startup()


$obj = Obj1()
$obj.ClickMe()              ; <<-- works fine
$obj.Something.Dummy()      ; <<-- also works fine
;$obj.Something("New")    <<--- why this line fails?

$obj2 = Obj2()
$obj2("New").ClickMe()  ; <<-- and this one does not

Func Obj1()
   Local $oClass = _AutoItObject_Class()
   With $oClass
      .AddMethod("ClickMe", "__obj1_clickme")
      .AddProperty("Something", $ELSCOPE_READONLY, Obj2())
   EndWith
   Return $oClass.Object
EndFunc

Func Obj2()
   Local $oClass = _AutoItObject_Class()
   With $oClass
      .AddMethod("__default__", "__default_object2_")
      .AddMethod("Dummy", "__obj2_clickme")
      .AddProperty("Object", $ELSCOPE_READONLY, Null)
      .AddProperty("Name", $ELSCOPE_READONLY, Null)
   EndWith
   Return $oClass.Object
EndFunc

Func Obj3()
   Local $oClass = _AutoItObject_Class()
   With $oClass
      .AddMethod("ClickMe", "__obj3_clickme")
   EndWith
   Return $oClass.Object
EndFunc

Func __default_object2_($oSelf, $sName)
   #forceref $oSelf
   If $oSelf.Object = Null Then $oSelf.Object = Obj3()
   $oSelf.Name = $sName
   Return $oSelf.Object
EndFunc

Func __obj1_clickme($oSelf)
   ConsoleWrite('clickme1' & @crlf)
EndFunc

Func __obj2_clickme($oSelf)
   ConsoleWrite('clickme2' & @crlf)
EndFunc

Func __obj3_clickme($oSelf)
   ConsoleWrite('clickme3' & @crlf)
EndFunc

 

Posted

Would this basically achieve the same objective?

$obj.Something.New("NewThing")

Func Obj1()
   Local $oClass = _AutoItObject_Class()
   With $oClass
      .AddMethod("ClickMe", "__obj1_clickme")
      .AddMethod("New", "__obj1_new")
      .AddProperty("Something", $ELSCOPE_READONLY, Obj2())
   EndWith
   Return $oClass.Object
EndFunc

Func __obj1_new()
    ; ... new thing stuff
EndFunc

 

  • 5 months later...
Posted (edited)

People still using AIO these days? Any new performance or stability issues? I think I'm going to convert my project to it.

I did find that it wasn't working in Windows 10 x64 (unless using the 32-bit wrapper) but I found a v1.2.8.3 fork which works :)

Edited by JonusC
  • 4 months later...
Posted

I have the following object with a property that will store an array. This script work as I expected when I call Add method but crash when I call Destroy method. Functions __add and __destroy have a very similar code I obviously I can't see where the problem is. Even if I comment the line where I redimension the array or if I create a new array when I call Destroy method the script will crash. Some ideas why? 

#include <AutoItObject.au3>
#include <Array.au3>

_AutoItObject_Startup()

$oTest = Test()
$oTest.Add('Test1')
$aObjects = $oTest.Objects
_ArrayDisplay($aObjects)
$oTest.Add('Test2')
$aObjects = $oTest.Objects
_ArrayDisplay($aObjects)
$oTest.Destroy

Func Test()
    Local $aObjects[1]
    $oTest = _AutoItObject_Class()
    With $oTest
        .AddMethod('Destroy','__destory')
        .AddMethod('Add','__add')
        .AddProperty('Objects', $ELSCOPE_PUBLIC, $aObjects)
    EndWith
    Return $oTest.Object
EndFunc

Func __add($oThis, $Name)
    Local $aObjects = $oThis.Objects
    _ArrayAdd($aObjects,$Name)
    $oThis.Objects = $aObjects
EndFunc

Func __destroy($oThis)
    Local $aObjects = $oThis.Objects
    ReDim $aObjects[1]
    $oThis.Objects = $aObjects
EndFunc

 

Posted

It's always a good idea to post all error messages you get ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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 (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

The requested action with this object has failed.:
$oTest.Destroy
$oTest^ ERROR

 

Edit: I see where the problem is, a typo in function name :blink:

Edited by Andreik
Posted

I suggest to add a COM error handler. This gives us more detailed error information.
An example can be found in the help file for ObjEvent.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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 (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I see :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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 (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 2 weeks later...
Posted

Andreik already noticed on 23th of May what caused th problem ;)

Quote

Edit: I see where the problem is, a typo in function name :blink:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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 (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • 2 years later...
Posted

Can someone point me in the right direction?

I've just stumbled upon AutoIt Object when looking for a way to take full webpage screenshots.  The solution I found has AutoIt Object as a pre-requisite.

However, I'm struggling to find a way in.  I've got the AutoItObject.au3 file in the include folder but I can't find any instructions on what other files from the download package go where.  The screenshot code is currently failing to compile with _AutoItObject_WarpInterface(): undefined function.

Any pointers on where to look for guidance on how to install would be appreciated

Posted (edited)

I don't know if this function is included in AutoItObject UDF but this is what are you looking for, just add it in your script:

Func _AutoItObject_WarpInterface($Obj, $IID, $Tag, $fNoUnknown = False)
    If Not IsDllStruct($IID) Then $IID = _AutoItObject_CLSIDFromString($IID)

    If Not IsObj($Obj) Then Return SetError(1, 0, 0)

    Local $pObj = _AutoItObject_IDispatchToPtr($Obj)
    If Not _AutoItObject_IUnknownAddRef($Obj) Then Return SetError(1, 0, 0)
    Local $ObjWarpped = _AutoItObject_WrapperCreate($pObj, $dtagIUnknown, $fNoUnknown)
    Local $aCall = $ObjWarpped.QueryInterface(Number(DllStructGetPtr($IID)), 0)
    If Not IsArray($aCall) And $aCall[0] <> 0 Then Return SetError(1, 0, 0)

    Local $pInterface = $aCall[2]
    Return _AutoItObject_WrapperCreate($pInterface, $Tag)
EndFunc   ;==>_AutoItObject_WarpInterface

 

Edited by Andreik

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...