Jump to content

Recommended Posts

Posted (edited)

version: 2.0.0

So many new changes :)

Most notably, the change of Github repository. This project, now has it very own Github repository, for less obscurity with issues and releases.

Edited by genius257
fixed changes link
Posted

Hello. ChangeLog says. [2.0.0] - 2017-07-07 I think is [2.0.0] - 2018-07-07

Between nice update.

 

Saludos

Posted (edited)

Edit. Deleted.

 

Saludos

Edited by Danyfirex
Posted
  On 7/8/2018 at 1:55 PM, Danyfirex said:

Hello. ChangeLog says. [2.0.0] - 2017-07-07 I think is [2.0.0] - 2018-07-07

Between nice update.

 

Saludos

Expand  

Ooops :> yeah my mistake.

Thanks for noticing ^^ i will change that immediately.

  • 1 month later...
  • 1 year later...
Posted

Can this be used like in AutoItObject with this example:

 

?

 

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Hi @MrCreatoR.

I think you're asking if AutoItObject Internal can be used with ObjGet?

 

This is something that CAN work, but for me it's in the alpha stage.

I have unpublished code, where this works somewhat by registering an object with the Running Object Table, but I have yet to solve an issue where the obj ref count gets messed up, due to Release being called more times than the AddRef method for some strange reason.

My theory is that i somehow handle the QueryInterface method wrong in some cases, but i have yet to find the precise problem.

 

TLDR;

not currently, sorry.

Posted
  On 4/29/2020 at 11:38 AM, genius257 said:

I think you're asking if AutoItObject Internal can be used with ObjGet?

Expand  

Yes, this also. I want to use it for interaction between process, to pass any type of data over COM object.

  On 4/29/2020 at 11:38 AM, genius257 said:

not currently, sorry.

Expand  

It's ok, keep up the good work you do, thanks for that.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 9 months later...
Posted

Hi @genius257,

thanks a lot for the effort on this! amazing.

based on this, I've created a very simple IPC solution: 

 

 

I've noticed in the event viewer, that when executing my examples, there seems to be an application crash. Sometimes it's in the ntdll, sometimes in combase. I didn't notice those crashes in autoit, because the two example scripts seem to run fine except (except when they dont).

I am quite sure, I am not using your Library as intended - could you be so kind to take a look at the linked post (and the files attached there) and let me know what I could be doing wrong.

Thanks & best regards, 

Posted (edited)

Hi @SEuBo.

Thanks! :) happy to know you like it.

Pretty cool idea. I've got work in progress for adding ROT functionality with my AutoObject_Internal, so if i work out the kinks, you won't need AutoItObject also :)

I can't seem to reproduce the problems you seem to describe (tested on win10).

IPC with AutoObject_Internal is unstable and very unpredictable currently.

Your usage, besides using it between processes seems to be fine :)

While current version is mostly stable, many edge cases makes the code more like a beta release currently. The issue for me is shallow COM interface documentation from MSDN and not many seems to report errors with the project (if more than a handful of people are using it).

 

My best guesses currently for the problem would be:

  • The reference count may reach 0 and trigger the object to release the memory (a bug with IPC i am looking into)
  • Currently i return no info from the TypeInfo part of IDispatch interface. This seems to cause no problems most of the time, but i suspect it may be the cause for crashes in some cases.

I will be happy to try and look into it, if I'm able to reproduce the bug reliably :)

Edited by genius257
  • 2 weeks later...
Posted (edited)

Hi @genius257,

Do we have a chance to make this method call work withouth the extra paranthesis?

($oObject.Method1)("Test")
#include <AutoItObject_Internal.au3>
#include <Array.au3>

#AutoIt3Wrapper_Run_Au3Check=n
Local $aArray[3] = [1, 2, 3]

$oObject = IDispatch()
$oObject.Method1 = _method1
$oObject.Method2_with_byref = _TestMethodByref

; Test Method1
($oObject.Method1)("Test")
$oObject.Method1("Test2")


; Test Method 2
_ArrayDisplay($aArray)
($oObject.Method2_with_byref)($aArray, "New Value")
$oObject.Method2_with_byref($aArray, "Aw, Shit")
_ArrayDisplay($aArray)


;MsgBox(0,"",VarGetType($oObject.Method1))
;MsgBox(0,"",VarGetType($oObject.Method1("vargettype")))

Func _method1($vParam)
    MsgBox(0,"",$vParam)
EndFunc

Func _TestMethodByref(ByRef $aData, $sText)
    ReDim $aArray[UBound($aArray) + 1]
    $aArray[UBound($aArray)-1] = $sText
EndFunc

I tried to play with the Invoke Function and in an seperate $DISPATCH_METHOD section under the $DISPATCH_PROPERTYGET, I managed to get the arguments from rgvargs but i'm not sure on how to proceed and invoke the actual function. 

I have now added a new section for $DISPATCH_METHOD to the Invoke()-Function. It's near the bottom and begins with:

If BitAND($wFlags, $DISPATCH_METHOD) = $DISPATCH_METHOD Then

I've also changed the lines for $DISPATCH_PROPERTYPUT and $DISPATCH_PROPERTYGET (I think the BitAnd wasn't really correct.)

  Reveal hidden contents

 

I didn't manage to get the functions return value, and ByRef parameters still don't work except when using the extra parenthesis I wanted to get rid of, see below. i assume that is because with the parenthesis, it's 'accessing' the method member, thus receiving the function ptr, thus letting AutoIt handle the Byref because it's not tunneled through COM.

($oObject.Method2_with_byref)($aArray, "New Value") ; works with ByRef
$oObject.Method2_with_byref($aArray, "Oh No!") ; doesnt work

 

Any Ideas on Return value & ByRef?

 

/Edit2: or is there another way to define/call methods which I didn't see?

Edited by SEuBo
Posted

Hi @SEuBo.

  On 2/28/2021 at 3:58 PM, SEuBo said:

Do we have a chance to make this method call work withouth the extra paranthesis?

Expand  

Yes. if you use a getter. See /Examples/02 - Basic - Accessors.au3 for reference.

Why?

  Reveal hidden contents

 

  On 2/28/2021 at 3:58 PM, SEuBo said:

Do you have an Idea?

Expand  

Yeah but it's fiddly:

  Reveal hidden contents

If you want some help with the invoke function, let me know, but i need more details of what problem you're having.

Posted (edited)
  On 2/28/2021 at 9:37 PM, genius257 said:

Yes. if you use a getter. See /Examples/02 - Basic - Accessors.au3 for reference.

Why?

Expand  

It may be that I don't fully understand the library yet. I assumed that using an Accessor, I could only have one single parameter and could access other properties only by using the .parent-property. 

 

  On 2/28/2021 at 9:37 PM, genius257 said:

The $DISPATCH_METHOD flag is sent by AutoIt3 no matter if you try to call it, or simply get the value.

Expand  

that really sounds like it could become troublesome. I will watch out for this when digging deeper into this topic.

 

  On 2/28/2021 at 9:37 PM, genius257 said:

Getting the variant data value for a AutoIt3 function data type is not possible to my knowledge (upon further glance is may be possible but i don't have the answer now), unless you get it from AutoIt3 itself. You can see me doing just that here.

Expand  

Yes, I copied that behaviour in my version of the Invoke method. Did you take a look at Accessing AutoIt Variables from LarsJ? (I am sure you did). I will play around a bit more to see if I can get the behaviour I want.

 

  On 2/28/2021 at 9:37 PM, genius257 said:

If you want some help with the invoke function, let me know, but i need more details of what problem you're having.

Expand  

If you could take a look at the following script and the custom Invoke and tell me how I could get the return Value of method1, I would be pleased.

  Reveal hidden contents

 

  On 2/28/2021 at 9:37 PM, genius257 said:

more details of what problem you're having.

Expand  

No problem at all - I think I could work around everything using setters/getters and just accessing the properties directly.  I just see huge potential with this UDF and I want to make defining and calling "regular" methods more easy. That would also allow some kind of inheritance - or at least traits. This library deserves way more attention - but I feel like it need's to be more "accessible" and more generalized.

Edited by SEuBo
Posted
  On 2/28/2021 at 10:09 PM, SEuBo said:

It may be that I don't fully understand the library yet. I assumed that using an Accessor, I could only have one single parameter and could access other properties only by using the .parent-property. 

Expand  

Here is an example for using getter as a object method

#include "AutoItObject_Internal.au3"
#include <Array.au3>

$oObject = IDispatch()

$oObject.key = "initial value of key"
$oObject.__defineGetter('key', getter)

$oObject.key
$oObject.key()
$oObject.key('A')
$oObject.key(123, 456)
$oObject.key('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','X','Y','Z')
ConsoleWrite($oObject.key&@CRLF)

Func getter($AccessorObject)
    Local Static $counter = 0

    Local $oArguments = $AccessorObject.arguments
    Local $iArguments = $oArguments.length
    Local $aArguments = $oArguments.values

    ConsoleWrite(StringFormat("getter invoked with %d number of parameters:\n", $iArguments))
    Local $i
    For $i = 0 To $iArguments - 1 Step +1
        ConsoleWrite(StringFormat("\targument [%02d]: (%s) %s\n", $i + 1, VarGetType($aArguments[$i]), $aArguments[$i]))
    Next

    Local $returnVal = $AccessorObject.val
    $counter += 1
    $AccessorObject.val = StringFormat('this property has been accessed for read %d times', $counter)
    Return $returnVal
EndFunc

 

  On 2/28/2021 at 10:09 PM, SEuBo said:

that really sounds like it could become troublesome.

Expand  

Oh it already is :)

  On 2/28/2021 at 10:09 PM, SEuBo said:

If you could take a look at the following script and the custom Invoke and tell me how I could get the return Value of method1, I would be pleased.

Expand  

On line 434:

VariantCopy($pVarResult, $tPropertyTarget)

Should be:

VariantCopy($pVarResult, $tPropertyTarget.Variant)

You were parsing in a struct, where a ptr was expected ;)

  On 2/28/2021 at 10:09 PM, SEuBo said:

That would also allow some kind of inheritance

Expand  

I'm not sure, but maybe you need to look at __assign

Example:

#include <AutoItObject_Internal.au3>

$cFoo=IDispatch()

func cFoo_Method1($self)
;~ whatever we want to have shared as a method printing a property of the current object
ConsoleWrite($self.parent.Property1)
endfunc

$cFoo.Method1 = cFoo_Method1

$oFoo1=$cFoo

;~ Have independent propertyvalues
$oFoo1.Property1="Hello world 1"

$oFoo2=IDispatch()

$oFoo2.__assign($oFoo1)

$oFoo2.Property1="Hello world 2"

MsgBox(0, "", $oFoo1.Property1)
MsgBox(0, "", $oFoo2.Property1)

MsgBox(0, "", FuncName($oFoo1.Method1))
MsgBox(0, "", FuncName($oFoo2.Method1))

 

A side note: If you are looking into a more class like usage, I am working on another project for that au3Class (powered by AutoItObject_Internal). It does have the downside of requiring transpiling the code before running it, but allows for great overview. I am working on adding support for class extending, traits and interfaces :)

  • 8 months later...
Posted

Can someone show me a simple array and array 2d transfer between 2 scripts

Script 1:

#include "AutoItSharedData.au3"
Global $oShare = _AutoIt_SharedData_CreateOrAttach("mouseData")

Global $oShare.s_blue_arr[1][1] = [[$s[0],$s[1],$s[2],$s[3]] _
        , [$s_2[0],$s_2[1],$s_2[2],$s_2[3]]]


While 1
 sleep (10)
WEnd

 

Script 2:
 

#include "AutoItSharedData.au3"
Global $oShare = _AutoIt_SharedData_CreateOrAttach("mouseData")


While 1

    MsgBox (1,"",$oShare.s_blue_arr[0][0])

WEnd

 

Posted (edited)
  On 11/24/2021 at 6:15 PM, Dexter1993 said:

Can someone show me a simple array and array 2d transfer between 2 scripts

Script 1:

#include "AutoItSharedData.au3"
Global $oShare = _AutoIt_SharedData_CreateOrAttach("mouseData")

Global $oShare.s_blue_arr[1][1] = [[$s[0],$s[1],$s[2],$s[3]] _
        , [$s_2[0],$s_2[1],$s_2[2],$s_2[3]]]


While 1
 sleep (10)
WEnd

 

Script 2:
 

#include "AutoItSharedData.au3"
Global $oShare = _AutoIt_SharedData_CreateOrAttach("mouseData")


While 1

    MsgBox (1,"",$oShare.s_blue_arr[0][0])

WEnd

 

Expand  

Hi @Dexter1993.

First of all, you seem to use AutoItSharedData. It is dependent on this library, but it seems a little off-topic in this thread maybe?

But anyhow, here is an example for you:

Script 1:

#include <AutoItObject_Internal.au3>
#include <AutoItObject_Internal_ROT.au3>

Global $oShare = IDispatch()
; AutoIt3 does not currently support "inline"/anonymous array creation, so we need to assign it to a variable before use.
Global $aArray = [[1,2,3,4],[5,6,7,8]]

$oShare.array = $aArray

_AOI_ROT_register($oShare, "mouseData")

While 1
    Sleep(10)
WEnd

Script 2:

#include <Array.au3>
#include <AutoItObject_Internal.au3>
#include <AutoItObject_Internal_ROT.au3>

Global $oShare = ObjGet("mouseData")
Global $aArray = $oShare.array

_ArrayDisplay($aArray)

; To access array inline from object, the property must be wrapped in parentheses
MsgBox(0, "", ($oShare.array)[0][0])

While 1
    Sleep(10)
WEnd

 

Edited by genius257
typo
  • 4 months later...
Posted

@genius257

Thank you, I can't express how great this is!

Using this, I wrote the below function to read in an INI file as an object. Do you see any memory issues with creating the IDispatch object in the loop? For example, should I call __destructor after each pass or will that be done automatically on the next "$oThisSection = IDispatch()"?


_objINI.au3

#include "AutoItObject_Internal.au3"

$oColors = _objINI_create("colors.ini")
ConsoleWrite($oColors.dark.black & @CRLF)

Func _objINI_create($filename)
    ; check if file exists
    If Not FileExists($filename) Then
        Return -1
    EndIf

    ; read in the section names
    $aSectionNames = IniReadSectionNames($filename)
    If @error Then
        Return -2
    EndIf

    ;create the main object
    Local $objINI = IDispatch()

    ;loop through section names. create IDispatch object for each section
    Local $sectionName, $oThisSection
    For $i = 1 To $aSectionNames[0]
        $sectionName = $aSectionNames[$i]

        $aSectionData = IniReadSection($filename, $sectionName)
        If @error Then
            Return -3
        EndIf

        ;section object
        $oThisSection = IDispatch()
        For $j = 1 To $aSectionData[0][0]
            ;add property to this section object
            $oThisSection.__set($aSectionData[$j][0], $aSectionData[$j][1])
        Next

        ;add this section to the main object
        $objINI.__set($sectionName, $oThisSection)
    Next

    Return $objINI
EndFunc   ;==>_objINI_create


colors.ini

[dark]
blue=#0000FF
black=#000000

[light]
yellow=#FFFF00
white=#FFFFFF

 

Posted

Hi @kurtykurtyboy.

You're welcome! I'm always happy to know people enjoy my projects :)

You don't need to call the __destructor method manually, it is all handled by AutoIt with the exception on script exit.

The object destructor function and object memory cleanup is invoked when no more references to the object exists. So for example if you overwrite your $oColors variable after your ConsoleWrite with something else, the object cleanup will run.

I see no issues with creating and assigning the objects within the loop, except you could end up allocating a lot of memory, if your ini file gets a lot bigger.

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