Hello,
I need to find the contents of a variable from another script. I found a long time ago on this forum the possibility to do it by adding this to my scripts:
objShell := ComObjCreate("WScript.Shell")
objEnv := objShell.Environment("Volatile")
Then using this format to read or write :
objEnv.Item("Test") := 1
It's ok, it works and I could do what I needed. However, if it works well for reading, this method is really slow for writing, it takes several seconds to change just a few variables.
Is there a faster method that allows me to realise this exchange of data between two scripts, or is it planned to improve this system ?
Rapid method to share between scripts ?
Re: Rapid method to share between scripts ?
Take your pick:
0. clipboard and/or hidden Gui
1. fileappend / fileread or iniwrite/read
2. same for dumping objects to files and read them back - https://github.com/ahkscript/awesome-Au ... ata-format
3. talk() https://autohotkey.com/board/topic/9432 ... -and-more/
4. OnMessage https://autohotkey.com/docs/commands/OnMessage.htm (working example posted)
5. .....
0. clipboard and/or hidden Gui
1. fileappend / fileread or iniwrite/read
2. same for dumping objects to files and read them back - https://github.com/ahkscript/awesome-Au ... ata-format
3. talk() https://autohotkey.com/board/topic/9432 ... -and-more/
4. OnMessage https://autohotkey.com/docs/commands/OnMessage.htm (working example posted)
5. .....
Re: Rapid method to share between scripts ?
What about IniRead and IniWrite?
Re: Rapid method to share between scripts ?
Using an ini file requires reading and writing to the hard disk, I suppose that realize this very regularly and for a very long time must certainly be bad.
I prefer not to use this method and keep the work in RAM.
I prefer not to use this method and keep the work in RAM.
Re: Rapid method to share between scripts ?
PostMessage / SendMessage may work to send values to another script. If you need to receive them, you can send a "request" message. Or there's an inherent "reply" feature to Post/Send message, not sure. I know there is some distinction between them explained in the docs, but it might just be an "acknowledge" kind of like WinWaitClose after using WinClose.
Re: Rapid method to share between scripts ?
Thank you, I did not know this method, I look if I can use it.
It seems rather complicated to use compared to objShell method. :/
It seems rather complicated to use compared to objShell method. :/
Re: Rapid method to share between scripts ?
Thanks !Invité wrote:Take your pick:
0. clipboard and/or hidden Gui
1. fileappend / fileread or iniwrite/read
2. same for dumping objects to files and read them back - https://github.com/ahkscript/awesome-Au ... ata-format
3. talk() https://autohotkey.com/board/topic/9432 ... -and-more/
4. OnMessage https://autohotkey.com/docs/commands/OnMessage.htm (working example posted)
5. .....
After a few tries, the talk() function seems to me the simplest. It is also very fast execution. The examples on the site are no longer available, here is the simplest method I have find to make it work:
I need a master script, and several other scripts that perform tasks. The master retrieves data from all these scripts. Here with 2 senders only, a fast example :
Master.ahk :
Code: Select all
#Include talk.ahk
loop
{
var1 := new talk("send1.ahk").getvar("var1")
var2 := new talk("send2.ahk").getvar("test1")
tooltip %var1% et %var2%
}
Code: Select all
#Include talk.ahk
new talk("Master.ahk")
loop
random, var1, 0, 100
Code: Select all
#Include talk.ahk
new talk("Master.ahk")
loop
random, test1, 0, 100
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Rapid method to share between scripts ?
This is a link to a hidden Gui solution:Guest wrote:Take your pick:
0. clipboard and/or hidden Gui
https://autohotkey.com/boards/viewtopic.php?t=3275
It is not as technically sophisticated but it is simple and works.
It allows you to do GuiVar_Set("Customer","Fanatic Guru') in any script to set a value to "Customer" and then use GuiVar_Get("Customer") in any scripts to retrieve the value of "Customer".
Any script can use GuiVar_Set and GuiVar_Get to set and get the value of an AHK wide "variable".
Looking at this now I really should have used a class but I was not as keen on classes three years ago.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
-
- Posts: 3
- Joined: 16 Dec 2016, 18:40
Re: Rapid method to share between scripts ?
create a file(.txt for example) and you can write and read it by all scripts
Re: Rapid method to share between scripts ?
What about read/write to a RAMdisk?
Re: Rapid method to share between scripts ?
I try your solution, and it work really well, easy and fast execution, A little simpler to set up than talk().FanaticGuru wrote: This is a link to a hidden Gui solution:
https://autohotkey.com/boards/viewtopic.php?t=3275
It is not as technically sophisticated but it is simple and works.
It allows you to do GuiVar_Set("Customer","Fanatic Guru') in any script to set a value to "Customer" and then use GuiVar_Get("Customer") in any scripts to retrieve the value of "Customer".
Any script can use GuiVar_Set and GuiVar_Get to set and get the value of an AHK wide "variable".
Looking at this now I really should have used a class but I was not as keen on classes three years ago.
FG
thanks