Sign in to follow this  
Followers 0
EmkioA

Share data between 2 instances of a script?

15 posts in this topic

Is there a way to share a variable between 2 instaces of the same script?

I need to detect if a script is run twice and the seconds time i need to make something defined by the first instance of the script

#include <Misc.au3>
Global $Running 


If _Singleton( "TestScript", 1 ) = 0 Then
 
 msgbox( 0, "", $Running )
    
Else
 
 $Running = 4
 msgbox( 0, "Test", "TestScript" )
 
EndIf

i would like to have a message box with 4 into the seconde instance of this script, how can i do this?

Stéphane

Share this post


Link to post
Share on other sites



You could create a window with a hidden style and send it a window message. I've used that before.

Share this post


Link to post
Share on other sites

I don't think this is possible.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

It is possible. The way I listed is just one way.

Share this post


Link to post
Share on other sites

Is there anything I could do to make you elaborate on that?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

How about asking the question, 'Could you help me on my way to solving this problem?'


[right]~What can I say, I'm a Simplistic person[/right]

Share this post


Link to post
Share on other sites

What I've done in the past is made a text file that the script can write your variable into and the second time it's run it checks to see if the variable is written there, if it is, do what you need to do otherwise write it.


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites

File writing isn't the best way to share data between processes because of the internal caching of the OS.

I don't know what more there is to elaborate. You create a hidden window. You watch for a message that you create. You have the second process find your hidden window and send it a message. That's not hard.

Share this post


Link to post
Share on other sites

What is the point of sending messages in that case?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

The whole purpose of the thread is interprocess communication. Sending a message from one program to another using window messages is a simple example of how to do that.

Share this post


Link to post
Share on other sites

Yes, that is exactly what I was talking about.

Share this post


Link to post
Share on other sites

Ok. Could communication be in both ways? Yashied's (nice work) is not example of intercommunication. He is practicing one-way communication.

(I was under impression you were talking about two-way communication)


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Ok. Could communication be in both ways? Yashied's (nice work) is not example of intercommunication. He is practicing one-way communication.

(I was under impression you were talking about two-way communication)

If you look more closely, then you will understand that the message is sent in both directions. The button "Send" is blocked until receiving a reply message. See also this example.

Share this post


Link to post
Share on other sites

If you look more closely, then you will understand that the message is sent in both directions. The button "Send" is blocked until receiving a reply message. See also this example.

Very nice Yashied. Thanks.

♡♡♡

.

eMyvnE

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