Recently Browsing 0 members
No registered users viewing this page.
while I created an example script to generate and execute a function during runtime, I stumbled across a neat way to share data between running autoit scripts.
This is done using the amazing magic of AutoItObject_Internal . (You'll need at least Version 3.0.0 of AutoItObject_Internal)
Using this UDF, you can create a shared data storage, basically an empty "AutoitObject_Internal-"Object which you can then use to write / read data Inline. no set/get methods, just
#include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") $oShare.some_data = 'foo' and you're done. any other script accessing this data will have to do:
#include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") ConsoleWrite($oShare.some_data & @LF)
Basically it's Larsj's Implementing IRunningObjectTable Interface, but you dont have a Dictionary, but an IDIspatch Object instead.
There are already a bunch of IPC options available - and this is another one.
Example Script 1
Example Script 2
To test: run Example Script 1, Then run example Script 2.. or the other way around.
Example Script 3
To test: run Example_sharedata3.au3.
/Edit: Please note that there's a limitation with the Running object table :
The Script accessing a variable first, will be the "server" for this variable. This means, access to that variable from other scripts should only be possible, as long the "server" script is running! Use appropriate Object Error handlers in case you don't want the surviving "clients" to crash.
Feedback and/or improvements appreciated
Removed need for AutoItObject, as AutoItObject_Internal now comes with ROT support Added UDF Header Fixed typo on "#include AutoItObjectInternal.au3" -> "#include AutoItObject_Internal.au3" Added ObjGet() after registering the object fails (in case 2 programs tried to register the same ID simultaneously) Updated Examples & zip archive. Cheers,
When I use DllStructCreate() to reserve a chunk of memory I would like to know if I can rely on that memory being initialized to zero. Experience suggests that it is, but I have been searching to try and find a definitive statement anywhere that this is the case. I apologise if I have missed somewhere. Part of the reason for this question is so that my next search (after my personal memory has dimmed) should yield a link to this post, hopefully with an answer.
A number of DLLs I use have structs where a few parts have to be explicitly set and other parts are reserved with the instruction that they must be set to zero. Because DllStructCreate() appears to zero-initialise the memory, I tend to forget to do it explicitly and everything seems to work. I am wondering whether I have been lucky and am storing up trouble for myself. It seems likely that the OS has been asked for zeroed memory, but without a promise in the documentation for DllStructCreate(), perhaps that could change? Perhaps the developers wish to reserve the right to change their minds?
so in https://www.autoitscript.com/forum/topic/193254-solved-ipc-between-system-and-user/ I asked around about IPCs and got all the answers I was looking for.
Now the question is: what IPC is most "resilient" on an overwhelmed PC, meaning, the CPU is at 100%, memory is top out and, as is always, need to rely on the IPC.
..and all this happened because I open over 100 GUIs at once 😜
..but it happens sporadically on low CPU or memory demand anyways.
..should I sleep() some time before running another instance ?
I did not know if to make the question in technical, chat, ..or here. So it's here.
Since you will ask what I've tried, I've used the IPC from the Fork UDFish ( WM_COPYDATA that can do Admin/user mix ) and the FMIPC file mapping, that work under the same conditions.
So, how do you handle IPC if it fails ?
I was in need of an IPC (Interprocess communication) between system, admin and user levels, and ended up writing this UDF to suit my wantings.
Hope you find it useful too.
Works from WinXP/Server2003 to the now current Win10/Server2016.
It communicates between any mix of x32, x64, Admin, User.
In the zip file, there is the UDF and an example: FMIPC(v0.2018.04.04).zip
Special thanks to @RTFC for the help in the support forum