Jump to content

Conceptual Question


Recommended Posts

Hi folks

have 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)


    While 1
        $msg = GUIGetMsg()
            Case $msg = $GUI_EVENT_CLOSE
            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" )


on 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 Regards


Link to comment
Share on other sites

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?

Link to comment
Share on other sites

i tried

ShellExecute ("C:\Program Files\AutoIt3\Beta\AutoIt3.exe","C:\Documents and Settings\Scarlett\Desktop\s2.au3")


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. >_<

Link to comment
Share on other sites

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 by athiwatc
Link to comment
Share on other sites

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

; 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"')

Second method would entail you to compile script 1 to an exe using the Beta build.

; 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"')

Ed: damn too slow, must be getting old. >_<

Edited by Mobius


Link to comment
Share on other sites

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.

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

  • Recently Browsing   0 members

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