2 x GUI Fenster starten

  • Bestimmt ganz einfach für euch :D

    aber ich bekomme ne krise :tier:

    also ich möchte einfach 2 Gui´s gleichzeitig starten

    bei mir startet zwar das erste Fenster aber dann macht der ne pause bis ich das erste Fenster schliesse.

    Ich möchte aber beide Fenster offen haben und in beiden Fenstern sollen die buttons usw noch funktionieren.

    Also was mache ich falsch ???

    später soll es halt ein tray icon werden und vom tray sollen 1,2,3 fenster gestartet werden.

    [autoit]


    #Include <Constants.au3>
    #include <GUIConstants.au3>
    #NoTrayIcon

    [/autoit][autoit][/autoit][autoit]

    Call("fenster1")
    Call("fenster2")

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func fenster1()
    GUICreate("FENSTER 1")

    [/autoit][autoit][/autoit][autoit]

    Opt("GUICoordMode",2)
    $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

    [/autoit][autoit][/autoit][autoit]

    GUISetState ()

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $Button_1
    Run('Notepad.exe')
    Case $msg = $Button_2
    MsgBox(0, 'Testing', 'Button 2 was pressed')
    EndSelect
    Wend
    EndFunc

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func fenster2()
    GUICreate("FENSTER 2")

    [/autoit][autoit][/autoit][autoit]

    Opt("GUICoordMode",2)
    $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

    [/autoit][autoit][/autoit][autoit]

    GUISetState ()
    While 1
    $msg2 = GUIGetMsg()
    Select
    Case $msg2 = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg2 = $Button_1
    Run('Notepad.exe')
    Case $msg2 = $Button_2
    MsgBox(0, 'Testing', 'Button 2 was pressed')
    EndSelect
    Wend
    EndFunc

    [/autoit]
  • Hi,

    du kannst den GUIOnEventMode benutzen und dann erst beide Fenster aufbauen und dann eine Schleife setzen.
    Und benutze NIE WIEDER die Call-Funktion, keine Ahnung warum es die gibt ....

    Mfg

  • Hi danke für die schnelle antwort.

    ich habe mal das beispiel script von autoit genommen für GUIOnEventMode.

    [autoit]


    #include <GUIConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
    $mainwindow = GUICreate("Hello World", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    $okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
    GUICtrlSetOnEvent($okbutton, "OKButton")

    [/autoit][autoit][/autoit][autoit]

    $dummywindow = GUICreate("Dummy window for testing ", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

    [/autoit][autoit][/autoit][autoit]

    GUISwitch($mainwindow)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    While 1
    Sleep(1000) ; Idle around
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func OKButton()
    ;Note: at this point @GUI_CTRLID would equal $okbutton
    MsgBox(0, "GUI Event", "You pressed OK!")
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    Func CLOSEClicked()
    ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
    ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
    If @GUI_WINHANDLE = $mainwindow Then
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
    EndIf
    EndFunc

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]

    Problem ist das er zwar das zweite Fenster aufruft aber dann wenn das zweite offen ist keine Funktion auf Fenster eins gibt bis das zweite fenster geschlossen wird.

    Es müssen halt beide fenster immer funktionieren.

    Funktioniert das nur mit @SW_HIDE / SHOW ??

    • Offizieller Beitrag

    Hi,

    [autoit]


    #include <GUIConstants.au3>
    $main_GUI = GUICreate("Main GUI", 300, 100, 10, 10)
    $b_1 = GUICtrlCreateButton("Click me 1", 10, 10, 80, 20)
    GUISetState(@SW_SHOW, $main_GUI)

    [/autoit][autoit][/autoit][autoit]

    $child_GUI = GUICreate("Child GUI", 300, 100, 330, 10, Default, Default, $main_GUI)
    $b_2 = GUICtrlCreateButton("Click me 2", 10, 10, 80, 20)
    GUISetState(@SW_SHOW, $child_GUI)

    [/autoit][autoit][/autoit][autoit]

    While 1
    $msg = GUIGetMsg(1)
    Select
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $main_GUI
    MsgBox(16, "MAIN", "Closed MAIN", 2)
    Exit(0)
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $child_GUI
    MsgBox(16, "CHILD", "CLOSED CHILD", 2)
    GUIDelete($child_GUI)
    Case $msg[0] = $b_1 And $msg[1] = $main_GUI
    MsgBox(16, "MAIN", "Button 1", 2)
    Case $msg[0] = $b_2 And $msg[1] = $child_GUI
    MsgBox(16, "CHILD", "Button 2", 2)
    EndSelect
    WEnd

    [/autoit]

    Edit: Call gibt es um Funktionen per String aufzurufen.

    So long,

    Mega

  • Sorry nochmals war doch nicht ganz 100% das was ich gesucht habe.

    also ich hab das jetzt so gelöst.

    Das ist im tray !

    [autoit]


    #Include <Constants.au3>
    #NoTrayIcon

    [/autoit][autoit][/autoit][autoit]

    Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown.

    [/autoit][autoit][/autoit][autoit]

    $fenster1 = TrayCreateItem("Fenster 1")
    TrayCreateItem("")
    $fenster2 = TrayCreateItem("Fenster 2")
    TrayCreateItem("")
    $exititem = TrayCreateItem("Exit")

    [/autoit][autoit][/autoit][autoit]

    TraySetState()

    [/autoit][autoit][/autoit][autoit]

    While 1
    $msg = TrayGetMsg()
    Select
    Case $msg = 0
    ContinueLoop
    Case $msg = $fenster1
    If ProcessExists("fenster1.exe") Then ;exisitier fenster1 dann nicht nochmal starten
    WinActivate("Fenster 1", "")
    WinFlash('Fenster 1',"", 4, 200)
    Else
    Run("fenster1.exe", "")
    EndIf
    Case $msg = $fenster2
    If ProcessExists("fenster2.exe") Then ;exisitier fenster2 dann nicht nochmal starten
    WinActivate("Fenster 2", "")
    WinFlash('Fenster 2',"", 4, 200)
    Else
    Run("fenster2.exe", "")
    EndIf
    Case $msg = $exititem
    $PID = ProcessExists("fenster1.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)
    $PID2 = ProcessExists("fenster2.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID2 Then ProcessClose($PID2)
    ExitLoop
    EndSelect
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Exit

    [/autoit][autoit][/autoit][autoit][/autoit]

    FENSTER 1 Compiliert als fenster1.exe

    [autoit]


    #include <GUIConstants.au3>
    #NoTrayIcon
    GUICreate("Fenster 1") ; will create a dialog box that when displayed is centered

    [/autoit][autoit][/autoit][autoit]

    Opt("GUICoordMode",2)
    $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

    [/autoit][autoit][/autoit][autoit]

    GUISetState () ; will display an dialog box with 2 button

    [/autoit][autoit][/autoit][autoit]

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $Button_1
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg = $Button_2
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    EndSelect
    Wend

    [/autoit][autoit][/autoit][autoit][/autoit]

    FENSTER 2 Compiliert als fenster2.exe

    [autoit]


    #include <GUIConstants.au3>
    #NoTrayIcon
    GUICreate("Fenster 2") ; will create a dialog box that when displayed is centered

    [/autoit][autoit][/autoit][autoit]

    Opt("GUICoordMode",2)
    $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

    [/autoit][autoit][/autoit][autoit]

    GUISetState () ; will display an dialog box with 2 button

    [/autoit][autoit][/autoit][autoit]

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $Button_1
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg = $Button_2
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    EndSelect
    Wend

    [/autoit]

    So klappts mit den Nachbarn :D

    nur sieht doof aus wenn man für ein script 3 exe dateien hat :rolleyes:
    Ich wollte es halt alles in einem script haben.

    • Offizieller Beitrag

    Hi,

    ist es das was du willst?

    Spoiler anzeigen
    [autoit]

    #Include <GUIConstants.au3>
    Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
    Opt("GUICoordMode", 2)

    [/autoit] [autoit][/autoit] [autoit]

    Global $1_S = True
    Global $2_S = True

    [/autoit] [autoit][/autoit] [autoit]

    $1 = GUICreate("Fenster 1", 300, 150, 10, 10) ; will create a dialog box that when displayed is centered
    $Button_11 = GUICtrlCreateButton("&1 Run Notepad", 10, 30, 100)
    $Button_22 = GUICtrlCreateButton("&2 Button Test", 0, -1)
    GUISetState(@SW_SHOW, $1)

    [/autoit] [autoit][/autoit] [autoit]

    $2 = GUICreate("Fenster 2", 300, 150, 350, 10, Default, Default) ; will create a dialog box that when displayed is centered
    $Button_1 = GUICtrlCreateButton("&3 Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("&4 Button Test", 0, -1)
    GUISetState(@SW_SHOW, $2)

    [/autoit] [autoit][/autoit] [autoit]

    $fenster1 = TrayCreateItem("Fenster 1")
    TrayCreateItem("")
    $fenster2 = TrayCreateItem("Fenster 2")
    TrayCreateItem("")
    $exititem = TrayCreateItem("Exit")
    TraySetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg(1)
    Select
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $1
    Exit (0)
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $2
    ExitLoop
    Case $msg[0] = $Button_11 And $msg[1] = $1
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg[0] = $Button_22 And $msg[1] = $1
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    Case $msg[0] = $Button_1 And $msg[1] = $2
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg[0] = $Button_2 And $msg[1] = $2
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    EndSelect
    $Traymsg = TrayGetMsg()
    Select
    Case $Traymsg = $fenster1
    ConsoleWrite(1 & @CRLF)
    If $1_S = True Then
    GUISetState(@SW_HIDE, $1_S)
    WinActivate("Fenster 1", "")
    WinFlash('Fenster 1', "", 4, 200)
    $1_S = False
    Else
    GUISetState(@SW_SHOW, $1_S)
    $1_S = True
    EndIf
    Case $Traymsg = $fenster2
    ConsoleWrite(2 & @CRLF)
    If $2_S = True Then
    GUISetState(@SW_HIDE, $2_S)
    $2_S = False
    Else
    GUISetState(@SW_SHOW, $2_S)
    $2_S = True
    EndIf
    Case $Traymsg = $exititem
    Exit (0)
    EndSelect
    WEnd

    [/autoit]

    So long,

    Mega

  • jain :)

    also es soll nur das tray icon erstmal kommen also nicht sofort die fenster.

    wieso beendet er fenster 2 wenn ich im tray wieder auf fenster 1 klicke ?
    Und wenn man ein Fenster schliesst, wird halt komplett das ganze tray geschlossen.

    Es soll halt so wie die 3 exe dateien funktionieren.
    Ist doch nicht so einfach mit den fenstern in Autoit.

    naja dann habe ich halt 3 exe dateien :hm:

    • Offizieller Beitrag

    Hi,

    Spoiler anzeigen
    [autoit]

    #Include <GUIConstants.au3>
    #Include <Constants.au3>
    Opt("TrayMenuMode", 1)
    Opt("GUICoordMode", 2)

    [/autoit] [autoit][/autoit] [autoit]

    Global $1_S = False
    Global $2_S = False

    [/autoit] [autoit][/autoit] [autoit]

    $1 = GUICreate("Fenster 1", 300, 150, 10, 10)
    $Button_11 = GUICtrlCreateButton("&1 Run Notepad", 10, 30, 100)
    $Button_22 = GUICtrlCreateButton("&2 Button Test", 0, -1)
    GUISetState(@SW_HIDE, $1)

    [/autoit] [autoit][/autoit] [autoit]

    $2 = GUICreate("Fenster 2", 300, 150, 350, 10, Default, Default)
    $Button_1 = GUICtrlCreateButton("&3 Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("&4 Button Test", 0, -1)
    GUISetState(@SW_HIDE, $2)

    [/autoit] [autoit][/autoit] [autoit]

    $fenster1 = TrayCreateItem("Fenster 1")
    TrayCreateItem("")
    $fenster2 = TrayCreateItem("Fenster 2")
    TrayCreateItem("")
    $exititem = TrayCreateItem("Exit")
    TraySetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg(1)
    Select
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $1
    GUIDelete($1)
    TrayItemSetState($fenster1, $TRAY_DISABLE)
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $2
    GUIDelete($2)
    TrayItemSetState($fenster2, $TRAY_DISABLE)
    Case $msg[0] = $Button_11 And $msg[1] = $1
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg[0] = $Button_22 And $msg[1] = $1
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    Case $msg[0] = $Button_1 And $msg[1] = $2
    Run('Notepad.exe') ; Will Run/Open Notepad
    Case $msg[0] = $Button_2 And $msg[1] = $2
    MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
    EndSelect
    $Traymsg = TrayGetMsg()
    Select
    Case $Traymsg = $fenster1
    If $1_S = True Then
    GUISetState(@SW_HIDE, $1)
    $1_S = False
    Else
    GUISetState(@SW_SHOW, $1)
    $1_S = True
    EndIf
    Case $Traymsg = $fenster2
    If $2_S = True Then
    GUISetState(@SW_HIDE, $2)
    $2_S = False
    Else
    GUISetState(@SW_SHOW, $2)
    $2_S = True
    EndIf
    Case $Traymsg = $exititem
    Exit (0)
    EndSelect
    WEnd

    [/autoit]

    So long,

    Mega