Rishav Posted August 25, 2009 Posted August 25, 2009 Hi folkshave a general question here. What are the different ways that i can invoke script 2 from script 1?For eg. take script 1;#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Local $Button_2, $msg GUICreate("My GUI Button") Opt("GUICoordMode", 2) $Button_2 = GUICtrlCreateButton("Button Test", 100, 100, 100, 50) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 ; Call the 2nd script here ; Run("C:\Documents and Settings\Scar\Desktop\s2.au3") ; ShellExecute ( "C:\Documents and Settings\Scar\Desktop\s2.au3" , 0, 0, "Run Script" ) EndSelect WEndon the button press, its supposed to call script 2 ;MsgBox(0, 'Testing', 'Button was pressed')The simplest way, of course, is to turn script 2 in a function and call it in 1st script. But in my real code, i have the 2nd script itself calling many functions and am rather anal about code structure.More importantly, i want the UI code to be completely separate from the called code so that maybe one day i can swap the UI with one made in QT without any major work.what are the different ways i can call up the 2nd script on pressing the button in script 1?ps. my shell execute and run commands don't work btw. >_< pps. another problem is that i should call the 2nd script in a way that it uses autoit Beta version. I am using many .NET features of the beta version currently.Thanks and RegardsRishav
WolfWorld Posted August 25, 2009 Posted August 25, 2009 Did you put the second script in Function? If so, get it out. There is no reflection or any mean alike so no you can't do that. Shell and Run should work by all means. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
Rishav Posted August 25, 2009 Author Posted August 25, 2009 ummm no. The 2nd script is just that msgbox command. my actual code for 2nd script is not a function either (but it does calls several functions) Any idea, how i can shellexecute the 2nd script so that it uses the Beta auotoit exe?
WolfWorld Posted August 25, 2009 Posted August 25, 2009 Oh you did not compile it yet. Try ShellExecute(%THE PATH TO THE AUTOIT BETA EXE%, "'Path to your script'") Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
Rishav Posted August 25, 2009 Author Posted August 25, 2009 i tried ShellExecute ("C:\Program Files\AutoIt3\Beta\AutoIt3.exe","C:\Documents and Settings\Scarlett\Desktop\s2.au3") and ShellExecute (%C:\Program Files\AutoIt3\Beta\AutoIt3.exe%,"C:\Documents and Settings\Scarlett\Desktop\s2.au3") in script 1 before compiling but i still couldn't make it work. the former gave me "Line 0 (File "C:\Documents"): Error: Error opening the file. " on running the compiled exe and the latter simply doesn't copiles due to syntax issues. Sorry, am new to the idea of compiling scripts. >_<
WolfWorld Posted August 25, 2009 Posted August 25, 2009 (edited) ShellExecute ("C:\Program Files\AutoIt3\Beta\AutoIt3.exe",'"C:\Documents and Settings\Scarlett\Desktop\s2.au3"') Try that and I do have a problem with Autoit beta before but that's a month ago and can't remember exactly what. Edited August 25, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
Rishav Posted August 25, 2009 Author Posted August 25, 2009 (edited) it works. >_< i'll try it out on my actual code first thing tomorrow. btw, what exactly do the single quotes do there? edited. the emoticon i chose was too gay. >.> Edited August 25, 2009 by Rishav
Mobius Posted August 25, 2009 Posted August 25, 2009 (edited) Hi folks have a general question here. What are the different ways that i can invoke script 2 from script 1? Hi Rishav, There are two ways to look at this.... First method is for when both files are in script form, Make sure Script 1 is executed with your beta build ;-Snip* ; Since Au3 beta is loaded with script 1 it will be loaded for script 2 also Case $msg = $Button_2 Run(@AUTOITEXE,'"C:\Documents and Settings\Scar\Desktop\s2.au3"') ;-Snip* Second method would entail you to compile script 1 to an exe using the Beta build. ;-Snip* ; Script 1 was created using Beta so script 2 will be executed with beta also (Script1.exe) Case $msg = $Button_2 Run(@AUTOITEXE,'/AutoIt3ExecuteScript "C:\Documents and Settings\Scar\Desktop\s2.au3"') ;-Snip* Ed: damn too slow, must be getting old. >_< Edited August 26, 2009 by Mobius
Rishav Posted August 25, 2009 Author Posted August 25, 2009 slow but still very useful. I didnt know about the @autoexe macro. this run command gives me yet another option that I can try. thanks a lot Athiwatc and Mobius. >_< though this should be what i need to proceed, if there are any other alternative ways, do let me know.
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