Yusuke Posted August 20, 2007 Share Posted August 20, 2007 Hi,Is there a way to launch an AutoIt script from another AutoIt script but that the child script can access the variables of the parent script ?Basically, I'm looking for something similar to the CALL command in batch scripting.VBScript also had something similar with ExecuteGlobal and I was happy with it, but I'm looking to completely switch to AutoIt now.Execute isn't what I want since it severely limits the usefulness of the child scripts.Environment, Files, Dir, Disk, GUI, InputBox, MsgBox, Misc, Network, Obj/COM, Process, Registry, Tray, WinKill functions implying deletion or modification will not be executed. They will set @error to 9999 and return "".Thanks a lot in advance. Link to comment Share on other sites More sharing options...
Tiger Posted August 20, 2007 Share Posted August 20, 2007 ShellExecute and then you can write in the another script "$CMDLINE" My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
Yusuke Posted August 20, 2007 Author Share Posted August 20, 2007 ShellExecute and then you can write in the another script "$CMDLINE"Thanks, but sorry, it is not exactly what I want : I know how to run another script, but what I would like to know if it is possible to to launch a child script and that this script can access the variables and functions of the parent script. Link to comment Share on other sites More sharing options...
James Posted August 20, 2007 Share Posted August 20, 2007 Add a function with another GUI in it. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 20, 2007 Share Posted August 20, 2007 Thanks, but sorry, it is not exactly what I want : I know how to run another script, but what I would like to know if it is possible to to launch a child script and that this script can access the variables and functions of the parent script.No. And BTW, that doesn't work with CALL in Windows shell scripting either. CALL spawns a separate shell with it's own copy of the environment. Any changes made generally only exist within that shell (SETX provides a way to change external environment variables), and are destroyed when you exit that shell.There are many ways to pass data between scripts, but not for directly reading the variables in another process. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Tiger Posted August 20, 2007 Share Posted August 20, 2007 Also you have an main script and achild script. run main script main script run child script is it so ok My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 20, 2007 Share Posted August 20, 2007 (edited) I created a demo a while back, specifically to demonstrate two AutoIt scripts communicating with each other by way of controls in each other's GUIs: Using GUI Controls for interprocess commsHope that helps... Zedna pointed out another great method (if you're into DLLs) using the WM_COPYDATA windows message: SendMessage Datastructure (reply by martin) Edited August 20, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Tiger Posted August 20, 2007 Share Posted August 20, 2007 I write a small script.Script: Main#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.9 Author: Tiger Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- MsgBox(64 + 8192, "", "Main-Script ist running") If MsgBox(32 + 4 + 8192, "", "Would you start the child-script?") = 6 Then ShellExecute(@AutoItExe, @ScriptDir & "\Child.au3 run") Else Exit EndIf My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 20, 2007 Share Posted August 20, 2007 I write a small script.That works to get the first script to run a second script, but does not do any communication between them. The first script will exit as soon as it launches the second, so they won't even be running together at the same time. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
piccaso Posted August 20, 2007 Share Posted August 20, 2007 check out CoProc (from my signature) it might be what you want. CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
Yusuke Posted August 21, 2007 Author Share Posted August 21, 2007 Thanks everyone. To explain a bit more what I wanted to do, I have a main GUI in a script that runs other scripts in subdirectories (the main script looks for *.au3 and launch them) and I wanted these child script to communicate with the GUI, and mostly an embedded IE Control. I have seen _IEAttach which allows me to get the object of the IE in my main window, so that's not too bad and will use that for now. It is a pity though that the Execute function is so limited.... VBScript's ExecuteGlobal was great for that. It is really handy to be able to access all the variables from the parent script from a child script without setting up WM_COPYDATA or TCP client/server. Just out of curiousity, anybody knows the reason for the Execute function to be so limited ? Security, I guess ? Link to comment Share on other sites More sharing options...
piccaso Posted August 21, 2007 Share Posted August 21, 2007 We convinced Jon to remove this limitation but it never happened... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now