Jump to content

Two Au3 Files Together


Recommended Posts

I am using one main .Au3 program and have another complete program in another .Au3 and don't want to put them together physically but want to be able to use the main.au3 to call the second and third. Usually I would use the GUICtrlSetOnEvent to call a function. Can I use the GUICtrlSetOnEvent to call another .au3 script? Like replace the code below "_function" with "second.au3" even though that won't work.. something like it?

I could make the second.au3 and third.au3 a function but the problem is each one has it's own internal functions and make the dominant script a function doesn't allow calling it's secondary functions.

#include <second.au3>
#include <third.au3>

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Close",$filemenu)
GUICtrlSetOnEvent($fileitem, "_Function")

Func _function()
Code here
Endfunc
Link to comment
Share on other sites

Like this...

_launchScript() returns the PID of the instance of the external running script

_launchScript(@scriptdir & "\second.au3")
_launchScript(@scriptdir & "\Third.au3")




Func _launchScript($vScript, $vWorkingDir = @ScriptDir)
    
    If NOT FileExists($vScript) then Return -1
    If @compiled then 
        Return Run(FileGetShortName(@ScriptFullPath) & " /AutoIt3ExecuteScript " &  FileGetShortName($vScript) , $vWorkingDir)
    Else
        
        Return Run (FileGetShortName(@AutoItExe) & " /AutoIt3ExecuteScript " &  FileGetShortName($vScript) , $vWorkingDir)
    EndIf
    
EndFunc
Link to comment
Share on other sites

Like this...

_launchScript() returns the PID of the instance of the external running script

_launchScript(@scriptdir & "\second.au3")
_launchScript(@scriptdir & "\Third.au3")




Func _launchScript($vScript, $vWorkingDir = @ScriptDir)
    
    If NOT FileExists($vScript) then Return -1
    If @compiled then 
        Return Run(FileGetShortName(@ScriptFullPath) & " /AutoIt3ExecuteScript " &  FileGetShortName($vScript) , $vWorkingDir)
    Else
        
        Return Run (FileGetShortName(@AutoItExe) & " /AutoIt3ExecuteScript " &  FileGetShortName($vScript) , $vWorkingDir)
    EndIf
    
EndFunc
Thank you very much. I was going on the right track with run but the FileGetShortName wasn't even considered. Thank you again. A good study.
Link to comment
Share on other sites

Thank you very much. I was going on the right track with run but the FileGetShortName wasn't even considered. Thank you again. A good study.

FileGetShortName() just gets round issues with long file paths with spaces in :)

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