Jump to content

Return to a specific point in another script


Go to solution Solved by ioa747,

Recommended Posts

Posted (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 by mr-es335
  • Solution
Posted

First off, a "Happy New Year!to you too  :)

 

Spoiler

 

Script1

#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

#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
;~ ; -----------------------------------------------

 

 

I know that I know nothing

Posted (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 by ioa747

I know that I know nothing

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