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 post
Share on other sites

Hi @TryingToCode,

this should be helpful:ย managing-multiple-guis ๐Ÿ˜€ .

Best regards

Stay innovative!


๐ŸŒย Au3Forums

๐Ÿ“Š AutoIt limits/defaults

๐Ÿ’Ž Code Katas: [...] (comming soon)

๐ŸŽญ Collection of GitHub users with AutoIt projects

๐Ÿžย False-Positives

๐Ÿ”ย Forum search

๐Ÿ”ฎย Me on GitHub

๐Ÿ’ฌย Opinion about new forum sub category

ย ๐Ÿ“‘ย UDF wiki list

โœ‚ย VSCode-AutoItSnippets

๐Ÿ“‘ย WebDriver FAQs

๐Ÿ‘จโ€๐Ÿซย WebDriver Tutorial (coming soon)

Link to post
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...