Jump to content

Recommended Posts

Posted

I am trying to get two scripts to "talk" to each other using EnvSet and EnvGet, but it doesn't seem to be working. The first script opens the second with a Run command, which works fine. It's just the Env variables not getting passed within a loop. I'll try to illustrate so it's a little clearer:

Snippet 1:

;Script1.au3
Run ("c:\program files\autoit3\AutoIT3.exe script2.au3")
EnvSet ("Env", "1")
Sleep (20000)
EnvSet ("Env", "2")

Snippet 2:

;Script2.au3
While 1
  $var = EnvGet ("Env")
  If $var = 1 Then
  MsgBox (0, "Debug", "I am 1")
  Elseif $var = 2 Then
  MsgBox (0, "Debug", "I am 2")
  Else
  MsgBox (0, "Debug", "I am not set")
  Endif
WEnd

Any help to get this to work is appreciated. thanks.

KilRoy

  • Moderators
Posted

I am trying to get two scripts to "talk" to each other using EnvSet and EnvGet, but it doesn't seem to be working. The first script opens the second with a Run command, which works fine. It's just the Env variables not getting passed within a loop. I'll try to illustrate so it's a little clearer:

Snippet 1:

;Script1.au3
Run ("c:\program files\autoit3\AutoIT3.exe script2.au3")
EnvSet ("Env", "1")
Sleep (20000)
EnvSet ("Env", "2")

Snippet 2:

;Script2.au3
While 1
  $var = EnvGet ("Env")
  If $var = 1 Then
  MsgBox (0, "Debug", "I am 1")
  Elseif $var = 2 Then
  MsgBox (0, "Debug", "I am 2")
  Else
  MsgBox (0, "Debug", "I am not set")
  Endif
WEnd

Any help to get this to work is appreciated. thanks.

KilRoy

Those 2 scripts will only pass information with EnvSet()/EnvGet() on the initial Run, to have 2 scripts communicate properly without using a File to write too (or an Ini or Registry), you may want to take a look at the StderrRead()/StdInWrite()/StdOutRead() commands in the Beta Help file.

Neogia had made some rountines for this that you can find in the Scripts and Scraps forum, I believe if you do an advanced search (For Titles) for MultiThread you will find it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...