Jump to content

How to pass string from AutoIt Exe to another one, and return back with other string ?


Daunra31
 Share

Recommended Posts

Hi !

I want to pass a string from an AutoIt script to another AutoIt Script.

So I use in the first script the function "ShellExecuteWait" to pass arguments (strings) and I recover them with $CmdLine[].

Until there, no problem.

Then, I want the second script to pass back another string to the first script.

Here I have a problem : I thought I could use the "Exit" function with a parameter (something like : Exit($MyString)) but this only works for integers !

So, does anyone can help me please ? Thanks

(If I am not clear enough, don't hesitate to tell me, I will post the scripts examples)

Link to comment
Share on other sites

You could write the information to a file and then delete it when you found and read the file with the first script.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

You could write the information to a file and then delete it when you found and read the file with the first script.

Yes, I though to do that, but it's not very practical :

In fact, I want the second executable to be like a kind of function for several other autoit executable. But I don't want to create an UDF file to include to each prog because I will change this "UDF" sometimes. And so I don't want to have to recompile each executable each time I will modify the "UDF"... (hope again i am clear...)

Link to comment
Share on other sites

This thread might help.
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.
Link to comment
Share on other sites

what about trying clipput and clipget to pass the information back and forth between the clipboard? no physical file to read or delete.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

This thread might help.

Thank you Martin but I don't see how this could help me...

what about trying clipput and clipget to pass the information back and forth between the clipboard? no physical file to read or delete.

Sorry Kaotkbliss I don't know how you "clipput and clipget", and even if I have an idea of what you mean, it doesn't seem to be the good way to do : my scripts will have to communicate a lot between them so I can't imagine a screen with some kind of clipboards appearing and disappearing (like some flashes!)

Your library seems to be the solution Yashied, thanks ! But, as I am not an expert, I have difficulties to visualise very clearly how I have to code this in my scripts... Don't you have little examples of scipt 1 and script 2 talking each other ?

So meanwhile, I am trying to use the MessageHandler.au3 library that you worked on to create yours (http://www.autoitscript.com/forum/index.php?showtopic=77979)

Link to comment
Share on other sites

What about using tcp/ip (127.0.0.1:port) ???

Cram.

Link to comment
Share on other sites

Sorry Kaotkbliss I don't know how you "clipput and clipget", and even if I have an idea of what you mean, it doesn't seem to be the good way to do : my scripts will have to communicate a lot between them so I can't imagine a screen with some kind of clipboards appearing and disappearing (like some flashes!)

Basically something like

Script 1

$variable="something"

clipput($variable)

script 2

$variable=clipget()

there are no extra windows opening or flashing

it all happens behind the scenes.

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

another option for passing information back and forth, especially if you have multiple variables that you need to send

iniread and iniwrite

again, another alternative that has no additional windows opening although it does create a very small .ini file

one script would

$var1="something"

$var2="somethingelse"

IniWrite("C:\name.ini","variable",1,$var1)

IniWrite("C:\name.ini","variable",2,$var2)

and name.ini is created

inside you would see

[variable]

1=something

2=somethingelse

the other script would then use

$newvar1=IniRead("C:\name.ini","variable",1,"")

$newvar2=IniRead("C:\name.ini","variable",2,"")

$newvar1 would = "something"

and $newvar2 would = "somethingelse"

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
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
 Share

  • Recently Browsing   0 members

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