Jump to content

Two GUIs but only one responds


Go to solution Solved by TryingToCode,

Recommended Posts

I'm struggling with 2 GUIs where one opens the other.  The first GUI successfully opens the second but then I can't get the second GUI to respond to any events or button presses.  Please could someone help identify what am I missing?

Here is some example code to illustrate my problem.

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)


Func Example()
    Global $hFirstGUI = GUICreate("First GUI", 330, 120)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI")
    Local $idNewGUI = GUICtrlCreateButton("New GUI", 10, 90, 85, 25)
    GUICtrlSetOnEvent(-1, "NewGUI")
    Local $idOK = GUICtrlCreateButton("OK", 240, 90, 85, 25)
    GUICtrlSetOnEvent(-1, "CloseGUI")
    GUISetState(@SW_SHOW, $hFirstGUI)
    While 1

Func CloseGUI()

Func NewGUI()
    Global $hSecondGUI = GUICreate("Second GUI")
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI2",$hSecondGUI)
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    GUICtrlSetOnEvent($idOK, "CloseGUI2")
    GUISetState(@SW_SHOW, $hSecondGUI)
    While 1

 Func CloseGUI2()

I'm using Opt("GUIOnEventMode", 1) because this is required elsewhere in my code.

Link to comment
Share on other sites

Hi @TryingToCode,

this should be helpful: managing-multiple-guis 😀 .

Best regards

Stay innovative!


🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

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