Sign in to follow this  
Followers 0
HCand

shared variables

11 posts in this topic

i've been looking a bit into the helpfiles and posts at the forum, and couldn't really find anything about this, so i'll ask..

is it possible to share variables and arrays between running scripts?

could that have anything to do with child processes? because i want it to be one program running more than one time, sharing the necessary variables,

so i can get past the fact that autoit will slow down when it handles greater mengths of data.

i'm still planning, so i dont have any actual code to show. but i hope you can help :D

Share this post


Link to post
Share on other sites



im not sure is i can be read from the memory from one app to another.

so why dont you save the array to an ini file.

then use other app to _FileReadToArray

well.. i wanted to be able to transfer the variables without putting anything through the harddisk, as it may wear it out in time.

but i'll look into that, thanks :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You could use WM_COPYDATA with SendMessage to send information between the applications. Pretty sure somebody posted some UDF for this in the Examples forum.

Its is also possible to use a hidden GUI with a number of controls that you modify in the other program using the control functions.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You could use WM_COPYDATA with SendMessage to send information between the applications. Pretty sure somebody posted some UDF for this in the Examples forum.

Its is also possible to use a hidden GUI with a number of controls that you modify in the other program using the control functions.

Jos

thanks.. gonna check up on those commands and the UDF. :D

Share this post


Link to post
Share on other sites

try Clipput() and clipget() writes to the clipbaord

yes, but clipput and clipget, when to go to the clipboard exactly? he needs a trigger!

use windows messages, it is the best solution for moving data between scripts. you will need both scripts to allways be in listening mode : guiregistermsg...

if you only want something simple use the clipboard and use something like

send ("{ctrl e}")

and in the other script use HotKeySet to get it. but here you will need a loop again.

the best solution were if JON will insert Object registaring to windows, then we were all happy.

Share this post


Link to post
Share on other sites

i've been looking a bit into the helpfiles and posts at the forum, and couldn't really find anything about this, so i'll ask..

is it possible to share variables and arrays between running scripts?

could that have anything to do with child processes? because i want it to be one program running more than one time, sharing the necessary variables,

so i can get past the fact that autoit will slow down when it handles greater mengths of data.

i'm still planning, so i dont have any actual code to show. but i hope you can help :D

There are various ways The fastest way to transfer data to another program is using messageas and reading memory.

Here is one example to look at. NOte that one line in each script needs to have comments removed if using the latest AutoIt Beta.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This method didn't interfere with the user's clipboard. I needed a way to get a string of over 300 bytes including @CR characters to another script. I thought at first I would have to convert the string to binary format, but that method didn't work for me.

In the data producing script I just put the string in a REG_SZ registry value:

RegWrite("HKEY_CURRENT_USER\Software\SquirrelWare\WeatherTray", "WeatherData", "REG_SZ", $_Return_Value)

And in the script that needs to receive the data I put this:

$reg_read = RegRead("HKEY_CURRENT_USER\Software\SquirrelWare\WeatherTray", "WeatherData")

I would sure like to know what the maximum size of data I can transfer this way, and what characters can not be used.

I think that much of the registry resides in memory but that what is there is eventually written to disk, as at logoff or shutdown. My machine uses a great big pagefile anyway since I only have 384 MB's of memory.

But in my experience, the registry can be written to and read from more quickly and reliably than a .ini file, and using the registry you won't need elaborate bloated code. :D

An easy way to pass $myArray if it isn't too big:

#include <Array.au3>
$myArrString = _ArrayToString($myArray, "|")
RegWrite($myRegistryKey, $myRegValuename, "REG_SZ", $myArrString)

And in the receiving script you would have this:

$reg_read = RegRead($myRegistryKey, $myRegValuename)
Sleep(140)
$myArray = StringSplit($reg_read, "|")

_ArrayDelete($myArray, 0)

Your array should now be in $myArray in the receiving script. If your array contains pipe characters - "|" - choose a different delimiter.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

There are various ways The fastest way to transfer data to another program is using messageas and reading memory.

Here is one example to look at. NOte that one line in each script needs to have comments removed if using the latest AutoIt Beta.

i wanted to see the script (edited first post) working, and then read the code. but it replies with an error when i start send.au3

Line -1: Error: can not redeclare a constant

should i use the one you originally posted instead?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

i wanted to see the script (edited first post) working, and then read the code. but it replies with an error when i start send.au3

Line -1: Error: can not redeclare a constant

should i use the one you originally posted instead?

If the const which is being redeclared is the one I commented out then just replace the comment. It depends on the version of AutoIt you are using, the predefined constants are changed with each release (some added some removed) .

In general if a Const is defined in a script and you get the error that it's already defined then just remove the declaration from your script.

Edit: I think that if you had the error Line -1 then you have compiled the script. If so then you don't need to do that. Just run the sender script from Scite if you use it.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  
Followers 0