Jump to content

Quit my Gui and function


Recommended Posts

Hello at all (first of all sorry for my bad english ;-) )

At the moment i want to greate a menu with diffrents function to help me at work. But i have 2 Problem (i post my code below)

You cann see i create a Menu and call this function.  At the moment i try to code my Button3 (Move IFMS).

You have to know, for 3 of 5 Buttons/executable i need a putty conection so i create a function initial_putty (here i have some input options Server, User, Password).

I want to call function this function in every function of the buttons (to inital my putty window)

Well, if i press my Button3 it jumps to my function moveifms (i delete the code from moveifms for a better overview). This function call my putty_inital_putty. Now i have 2 Problems

First problem: You can see i create a OK Button. If my input is done i want press OK Button, save the input in variables and close my Gui and go back to the caller function (move_ifms).

In for examble shell skripts i have the option break; to go back.

Can someone help me out? Is this a bad code idea? How i can save my input and go back to moveifms?

Best Regards

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <File.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>

Func initial_putty()

    Global $mhost = "", $muser = "", $mpassword = "";
    Local $msg
    $puttygui = GUICreate("Initial Connect", 200, 200)
    Local $Button1 = GUICtrlCreateButton("OK", 50, 150, 90, 30)
    Local $Button2 = GUICtrlCreateButton("Cancel", 120, 150, 90 ,30)
    GUICtrlCreateLabel("Hostname:", 10, 10, 100)
    GUICtrlCreateLabel("Username:", 10, 50, 100)
    GUICtrlCreateLabel("Password:", 10, 75, 100)


        $mhost = GUICtrlCreateInput("", 75, 5, 100, 20)
        $muser = GUICtrlCreateInput("", 75, 50, 100, 20)
        $mpassword = GUICtrlCreateInput("", 75, 75, 100, 20)

func moveifms()
                ;Here was some code but i delete better overview<----

func Menu()
    ;Variables for func Menu:
        Local $iMsg
        Local $iGUIWidth = 120, $iGUIHeight = 450

        ; Aufbau der Gui
        Local $windows = GUICreate ("SAP Helper GUI", $iGUIWidth, $iGUIHeight)
        Local $FileMenu = GUICtrlCreateMenu("File")
        Local $idExitItem = GUICtrlCreateMenuItem("Exit", $FileMenu)
        Local $HelpMenu = GUICtrlCreateMenu("?")
        Local $idAboutItem = GUICtrlCreateMenuItem("About", $HelpMenu)

        ;Aufbau der Buttons
        ;Breite; Höhe GuiFenster; Länge des Button; Höhe des Button
        Local $Button1 = GUICtrlCreateButton("Plan Jobs", 5, 25, 90, 30)
        Local $Button2 = GUICtrlCreateButton("Switch Kernel", 5, 65, 90, 30)
        Local $Button3 = GUICtrlCreateButton("Move IFMS File", 5, 105, 90, 30)
        Local $Button4 = GUICtrlCreateButton("Change Pass.", 5, 145, 90, 30)
        Local $Button5 = GUICtrlCreateButton("Exit", 5, 400, 90, 30)

        ;Starte Menu
            While 1
                $iMsg = GUIGetMsg()
                Switch $iMsg

                    Case $idExitItem

                    Case $idAboutItem
                    MsgBox($MB_SYSTEMMODAL, "About", "GUI Menu Test")

                    Case $Button1

                    Case $Button2

                    Case $Button3

                    Case $Button4

                    Case $Button5
                    MsgBox($MB_SYSTEMMODAL, "Bye, bye", "Programm will timeout after 5 seconds or select the OK button.", 5)


Link to comment
Share on other sites

A few things you need to change and add.

Don't declare Globals from within a function, declare them at the start of your script, after the #includes.

You have an illegal ExitLoop command in your inital_putty function ... there is no loop.

In fact, if you want to run a second GUI, you need a While 1 ... Wend loop in that, similar to what you have in your main() gui function.

I would also have the three create input lines before the GUISetState() command.

Personally, even though you are declaring your button create variables (handles) as Local, I would name them unique between the two GUI's.

When you add the While 1 ... Wend code to your inital_putty function, in the Case $button1 statement (OK button), I would add the commands GUIDelete($puttygui) and ExitLoop, so that code flow returns to the main() gui.

Once you do all that, and with a few testing MsgBox (if needed) you will begin to understand what is going on, better.

P.S. Welcome to the forum! :)

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


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