mr-es335 Posted Saturday at 03:06 PM Posted Saturday at 03:06 PM (edited) Good day, Firstly, I do hope that I have titled this posting appropriately? Secondly, I have the following scenario... 1) I have two scripts, Script1 and Script2 2) Script1, has a single button to go to the Group 6 Menu 3) The Group 6 Menu has two buttons, a) One button to return to the Main Menu b) One button to launch Script2 4) Selecting "Launch Script2" exits Script1 and launches Script2. • So far...so good...I think!? 5) Script2, has a single button to return to Script1 6) However, the script returns to the Main Menu of Script1 7) I want to return to the Group 6 Menu of Script1 The question then is, "How do I return to the Group 6 Menu of Script1 upon exit of Script2?" • I do hope that I am asking this question correctly? PS: I have modified the original scripts for this posting. Extract the ZIP file to the root of Drive C. • The folder is called, "Test" - of which contains two scripts, Script1 and Script2. Any assistance in this matter would be greatly appreciated! Testing.zip Edited Saturday at 04:12 PM by mr-es335 mr-es335 Sentinel Music Studios
Solution ioa747 Posted Saturday at 03:51 PM Solution Posted Saturday at 03:51 PM First off, a "Happy New Year!" to you too Spoiler Script1 expandcollapse popup#cs Filename: Script1 Calling Script2, then having Script2 return to a specific point in Script1. Status|Date: |01/04/25 #ce ; ----------------------------------------------- ; Root Section ; ----------------------------------------------- #include <GUIConstantsEx.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $ghGuiMainMenu Global $ghGuiGroup1 ; ----------------------------------------------- ; GuiMainMenu Main Section ; ----------------------------------------------- If $CmdLine[0] > 0 Then If $CmdLine[1] = "GuiGroup6" Then GuiGroup6() Else GuiMainMenu() EndIf ; ----------------------------------------------- Func GuiMainMenu() GUIDelete($ghGuiGroup1) ; ----------------- $ghGuiMainMenu = GUICreate("Script1", 235, 75) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- ; GuiMainMenu Button ; ----------------------------------------------- Local $sCol1Row6 = GUICtrlCreateButton("Group 6 Menu", 10, 10, 215, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $ghGuiMainMenu) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $sCol1Row6 GuiGroup6() EndSwitch WEnd EndFunc ;==>GuiMainMenu ; ----------------------------------------------- ; GuiGroup6 Main Section ; ----------------------------------------------- Func GuiGroup6() GUIDelete($ghGuiMainMenu) Local $ghMainGui6 = GUICreate("Group 6 Menu", 235, 75) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- ; GuiGroup6 Buttons ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("Main Menu", 10, 10, 215, 25) ; ----------------- Local $sCol1Row4 = GUICtrlCreateButton("Launch Script2", 10, 40, 215, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $ghMainGui6) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $sCol1Row1 GuiMainMenu() Case $sCol1Row4 LaunchScript2() Exit EndSwitch WEnd EndFunc ;==>GuiGroup6 ; ----------------------------------------------- ; GuiGroup6 Functions ; ----------------------------------------------- Func LaunchScript2() Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\Script2.au3"') ;~ ExitS1() EndFunc ;==>LaunchScript2 ; ----------------------------------------------- ;~ Func ExitS1() ;~ Local $_sSrcPath = "Group 6 Menu" ;~ ; ----------------------------------------------- ;~ WinClose($_sSrcPath) ;~ EndFunc ;==>ExitS1 ;~ ; ----------------------------------------------- Script2 expandcollapse popup#cs Filename: Script2 Have Script2 return to a specific point in Script1. Status|Date: |01/04/25 #ce ; ----------------------------------------------- ; Root Section ; ----------------------------------------------- #include <GUIConstantsEx.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $ghGuiMainMenu ; ----------------------------------------------- ; GuiMainMenu Main Section ; ----------------------------------------------- GuiMainMenu() ; ----------------------------------------------- Func GuiMainMenu() ;~ GUIDelete($ghGuiGroup1) ; ----------------- $ghGuiMainMenu = GUICreate("Script2", 235, 75) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- ; GuiMainMenu Button ; ----------------------------------------------- Local $sCol1Row6 = GUICtrlCreateButton("Return to Script1", 10, 10, 215, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $ghGuiMainMenu) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $sCol1Row6 Script1() Exit EndSwitch WEnd EndFunc ;==>GuiMainMenu ; ----------------------------------------------- ; GuiGroup6 Main Section ; ----------------------------------------------- Func Script1() ;~ The return point should be Func GuiGroup6() of Script1 Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\Script1.au3" GuiGroup6') ;~ ExitS2() EndFunc ;==>Script1 ; ----------------------------------------------- ;~ Func ExitS2() ;~ Local $_sSrcPath = "Script2" ;~ ; ----------------------------------------------- ;~ WinClose($_sSrcPath) ;~ EndFunc ;==>ExitS2 ;~ ; ----------------------------------------------- mr-es335 1 I know that I know nothing
mr-es335 Posted Saturday at 04:20 PM Author Posted Saturday at 04:20 PM ioa747, Thanks for this...appreciated...as always! May I ask, what this portion is doing? If $CmdLine[0] > 0 Then If $CmdLine[1] = "GuiGroup6" Then GuiGroup6() Else GuiMainMenu() EndIf Also, an interesting way of returning to the calling script!! Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\Script1.au3" GuiGroup6') mr-es335 Sentinel Music Studios
ioa747 Posted Saturday at 04:45 PM Posted Saturday at 04:45 PM (edited) check the in help file for "Command Line Parameters" Edited Saturday at 04:45 PM by ioa747 I know that I know nothing
mr-es335 Posted Saturday at 07:36 PM Author Posted Saturday at 07:36 PM ioa747, I did as you suggested...thanks. I gather that...the following command being "focused' on the command line, would be the reasoning behind the employment of the "If|Then" statement? Would this be a correct assertion? Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\Script1.au3" GuiGroup6') mr-es335 Sentinel Music Studios
ioa747 Posted Sunday at 01:50 AM Posted Sunday at 01:50 AM (edited) sorry but I don't understand you (your sentence doesn't make sense, and when I translate it, the meaning is confusing - and it's certainly not your fault but my limited knowledge of English) but since you have the data, you can try it, and see if it's a correct assertion ; # more detailed explanation: If $CmdLine[0] > 0 Then ;This line checks if there are any command-line arguments passed to the script. ;$CmdLine[0] contains the count of command-line arguments. ;If it is greater than 0, it means that at least one argument has been provided when the script was executed. If $CmdLine[1] = "GuiGroup6" Then GuiGroup6() ;It checks if the first command-line argument (which is $CmdLine[1], since $CmdLine[0] is the count) is equal to the string "GuiGroup6". ;If this condition is true, it calls the function GuiGroup6(). Else ;It is executed if the condition $CmdLine[0] > 0 is false, meaning no command-line arguments were provided. GuiMainMenu() ;it calls the function GuiMainMenu(). EndIf DuckDuckGo+AI+Chat Edited Sunday at 01:58 AM by ioa747 I know that I know nothing
mr-es335 Posted Sunday at 03:52 AM Author Posted Sunday at 03:52 AM ioa747, Thanks for the follow-up... May I ask where is the script are command-line arguments being passed? I have commented all but "GuiMainMenu()"...and I see no difference at all! mr-es335 Sentinel Music Studios
ioa747 Posted Sunday at 04:22 AM Posted Sunday at 04:22 AM (edited) command-line arguments are typically passed to a script when it is executed from a command prompt, a batch file, or a shortcut that includes arguments. take a look Comment-1540039 Comment-1503889 Edited Sunday at 05:17 AM by ioa747 I know that I know nothing
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