Jump to content

Recommended Posts

Posted

I didn't tested it yet, but can we pass arrays, objects that way?

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)
  On 2/12/2021 at 3:48 PM, MrCreatoR said:

I didn't tested it yet, but can we pass arrays, objects that way?

Expand  

Hey,

yes you can, see example for array & object (in array) below - I think problems only really occur with DLLStructs, Pointers and Function-References. Some types (like handles) have to be Hwnd()'ed again on the other side. As far as I understood, those are internal limitations. Larsj did a great job summarizing it here (scroll down to "data types"):

$aArray :     Array variable type.
$dBinary :    Binary variable type.
$bBoolean :   Bool variable type.
$pPtr :       Int32 variable type.
$hWnd :       Int32 variable type.
$iInt :       Int32 variable type.
$fFloat :     Double variable type.
$oObject :    Object variable type.
$sString :    String variable type.
$tStruct :    Not recognized as a valid variable type.
$vKeyword :   Keyword variable type.
fuMsgBox :    Not recognized as a valid variable type.
$fuFunc :     Not recognized as a valid variable type.
$fuUserFunc : Not recognized as a valid variable type.

 

Example SharedData4:

  Reveal hidden contents

384233565_GIF12_02.202119-20-33.gif.15aa26b83e1fac118871384269ab7963.gif

Edited by SEuBo
Posted

Great, i will test it soon, thanks for sharing!

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Thanks for sharing. Intriguing stuff that I just might use one day ... I see the possibilities.

Of course, like many I suspect, I have shared data between programs using an INI file entry or a Registry entry, probably even via SQL. I've also done it using STDOUT and STDIN by compiling to a console based executable. Your project however seemingly promises more and better. :)

Cheers

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted
  On 2/27/2021 at 6:52 AM, TheSaint said:

Thanks for sharing. Intriguing stuff that I just might use one day ... I see the possibilities.

Of course, like many I suspect, I have shared data between programs using an INI file entry or a Registry entry, probably even via SQL. I've also done it using STDOUT and STDIN by compiling to a console based executable. Your project however seemingly promises more and better. :)

Cheers

Expand  

Thanks for you kind words. I didn't do much but to stumble accross this (Even a blind squirrel finds a nut once in a while :)but I am glad you like it!

All credits go to @genius257 for AutoItObject_Internal and of course to the original AutoItObject-Team for their great effort.

Posted

From me as well : "Thanks for sharing" :thumbsup:

  On 2/27/2021 at 9:32 AM, SEuBo said:

I didn't do much but to stumble accross this (Even a blind squirrel finds a nut once in a while :))

Expand  

That is true, but it makes a big difference whether the nut is made of gold or is rotten. Moreover, finding something is only the first step. There must also be someone willing to spend his time to prepare something delicious from it (as you did) :D.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

Thank you SEuBo, very useful!

I found these limits with array:

you can set and change a string/number var etc, you can read array, but you can't set/change an array and you can't directly use UDF _array: i.e. _arrayDisplay($oShare.arr)

#include "AutoItShared/AutoItSharedData.au3"
#include <Array.au3>

$oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID")

$oShare.data = 'foo'

global $arr = [1,2]
;global $oShare.arr = [1,2] ; NO

$arr[1] = 4
$oShare.arr = $arr
msgbox(0,'', $oShare.arr[1]) ; OK
;~ $oShare.arr[1] = 5 ; NO

_arrayDisplay($arr) ; OK
;~ _arrayDisplay($oShare.arr) ; NO

can you overcome these?

Posted

Hey frank10,

those are unfortunately limitations of the AutoIt Parser, as far as I understand. 

I guess you have no chance, but to use a temporary variable.

 

Regarding the direct access of Array-Elements for writing, there is a potential workaround, which is still not pretty.
We could "fake" a method for all the Array data. This would be done by replacing your AutoItSharedData.au3 with the following file (for testing purposes:)

  Reveal hidden contents

Instead of

;~ $oShare.arr[1] = 5 ; NO

you could then write:

$oShare.arr(1) = 5

 

Not great, but at least something.

Posted
  On 3/8/2021 at 4:03 PM, SEuBo said:

Regarding the direct access of Array-Elements for writing, there is a potential workaround, which is still not pretty.

We could "fake" a method for all the Array data. This would be done by replacing your AutoItSharedData.au3 with the following file (for testing purposes:)

Instead of

;~ $oShare.arr[1] = 5 ; NO

you could then write:

$oShare.arr(1) = 5

 

Expand  

Great, a lot better!

It works also with 2D array:

global $arr = [[1,2],[3,4]]
$arr[1][0] = 8
$oShare.arr = $arr
$oShare.arr(1,1) = 9 

$temp = $oShare.arr
_arrayDisplay($temp)

 

Posted

Could you explain why I am receiving this error :

image.png.8fa30211e54bcacaf3829552efe03092.png

Test1.au3 :

#include "AutoItSharedData.au3"

$oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID")

$oShare.Request = @MSEC

Do
    Sleep(10)
Until $oShare.Response

MsgBox(64,"",$oShare.Request & "/" & $oShare.Response)

Test2.au3 :

#include <AutoItSharedData.au3>

$oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID")

Do
    Sleep(10)
Until $oShare.Request

$oShare.Response = @MSEC

If I run Test2 first, and then Test1 I get the error.  

Posted

Hi Nine,

contrary to what I've said in the first post about "the first script accessing a variable":

My best guess is that because Test2.au3 is the last script to assign any value within $oShare, it becomes the "Server" for this IDispatch.
Even though the behaviour isn't really consistent. I'd have to dig into that.

Potential workarounds:

1) Add Sleep(100) as last line of Test2.au3, like so:

#include <AutoItSharedData.au3>

$oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID")

Do
    Sleep(10)
Until $oShare.Request

$oShare.Response = @MSEC
Sleep(100)

2) OR: Add Error-Handler into Scripts, like so:

#include "AutoItSharedData.au3"

$oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID")
$oError = ObjEvent("AutoIt.Error", _ErrorHandler)

$oShare.Request = @MSEC

Do
    Sleep(10)
Until $oShare.Response

MsgBox(64,"",$oShare.Request & "/" & $oShare.Response)


func _ErrorHandler($oObject)
    SetError($oObject.number)
EndFunc

 

I'll investigate this later today.

Cheers,

Posted (edited)

There is also a problem with handles:

local $hWin = WinGetHandle("[active]")
$oShare.hGUImain  = $hWin ; it also stores it in Decimal...
ConsoleWrite($hWin & "___" & Hex($oShare.hGUImain) & @CRLF)
Local $aGUI_Main_Pos = WinGetPos($hWin)
ConsoleWrite("Pos hWin:"  & $aGUI_Main_Pos[0]  & @CRLF)

Local $aGUI_Main_Pos = WinGetPos($oShare.hGUImain)
ConsoleWrite("Pos oShare:"  & $aGUI_Main_Pos[0] & @CRLF) ; ERR
 
Local $aGUI_Main_Pos = WinGetPos( HWND($oShare.hGUImain) ) ; THIS works
ConsoleWrite("Pos oShare:"  & $aGUI_Main_Pos[0] & @CRLF) ; OK

EDIT

You should detect if there is a handle and store it as 0xHexNumber into the share var.

Edited by frank10
Posted (edited)

I would like to change some control settings of a GUI created from another script.

I got Get/Set with ControlGetText and ControlSetText, because original funcs like GUICtrlRead does not work in the script that didn't create the GUI.

Is there a way to use those original funcs also in the other script?

i.e. GUICtrlSetBkColor or GUICtrlSetImage

 

Edited by frank10
  • 3 months later...
Posted (edited)

Is there a limit on the number and long of "variables"?
I mean $oShare.xxx.

Is there a command to erase the values of all variables of $oShare ?

 

Edited by Lion66
add question
  • 2 weeks later...
Posted (edited)

I'm still looking, how clean all data from Object without destroy it.
I found function VariantClear, but how I get list of all variables into object ?
Does anyone understand to help me?

Edited by Lion66
Posted

This is the first time I have used AutoitObject.
I'm not sure if my question is related to this UDF, or if it is a more general question about Objects.
I'll ask here. Help me 🙂.
How to set the name and value of an object variable through function parameters?

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

_SharingSetData("1", "aaa")

Func _SharingSetData($Var, $String)

    $oShare.Variable($Var) = $String

    MsgBox(0,"", $oShare.Variable1)
EndFunc

 

Posted

I decided with the help of an array.

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

_SharingSetData("1", "aaa")

Func _SharingSetData($Var, $String)
    Local $arr[1]
    $oShare.Variable = $arr
    $oShare.Variable($Var) = $String

    MsgBox(0,"", $oShare.Variable($Var))
EndFunc

 

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