Jump to content

Multiple GUI blocks previous ones


Afaren
 Share

Recommended Posts

Hello,

I'm fairly new to coding with Autoit and I have no real coding experience, so don't worry if I look stupid.

I explain you my problem. I did a GUI with an option button, this button opens another GUI  which I can interact with, but when I come back to the previous GUI (that was left open), I can't interact with it anymore.

Have you already encoutered such problem ?

Thank you in advance for any help.

Link to comment
Share on other sites

  • Moderators

Afaren,

Welcome to the AutoIt forums.

I suggest reading the Managing Multiple GUIs tutorial in the Wiki to understand how to get your various GUIs playing nicely with each other.

If you still have problems, then post your code so we can take a look - see here how to do it.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hello again,

I found another problem, and I don't know why it happens. When I create the second gui, the close button works fine and the first gui works fine too, but when I create a third gui from the second (guiception) and I close it, everything works fine, except the second gui's close button that doesn't work...

Here is a part of my code

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <GUIHotkey.au3>

$drive = @WorkingDir
$options = "[Owlolf] Options.txt"
Global $Form2, $Form3, $g_idButton, $g_idButton2, $CleanHotkey, $HotkeyClean
Opt("GUIOnEventMode", 1)

gui1()

Func gui1()

    #Region ### START Koda GUI section ### Form=C:\Users\Afaren\Desktop\Test\Automatismes.kxf
    Local $Form1 = GUICreate("[Owlolf] Wolf's Edits", 237, 29, 1015, 0)
        GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui1")
    Local $Button1 = GUICtrlCreateButton("Clean", 0, 0, 67, 25)
        GUICtrlSetOnEvent(-1, "On_Clean")
    Local $Button2 = GUICtrlCreateButton("p1", 72, 0, 75, 25)
        GUICtrlSetOnEvent(-1, "On_p1")
    Local $Button3 = GUICtrlCreateButton("Options", 152, 0, 75, 25)
        GUICtrlSetOnEvent(-1, "On_Options")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    WinSetOnTop("[Owlolf] Wolf's Edits", "", 1)

    While 1
        Sleep(10)
    WEnd
EndFunc

Func gui2()

    #Region ### START Koda GUI section ### Form=C:\Users\Afaren\Desktop\Test\Owlolf\Options.kxf
    Local $Form2 = GUICreate("[Owlolf] Options", 228, 183, 1110, 109)
        GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui2")
    Local $Group1 = GUICtrlCreateGroup("Gestion des raccourcis clavier", 0, 8, 225, 73)
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    Local $CleanHotKeyButton = GUICtrlCreateButton("Clean", 24, 32, 73, 33)
        GUICtrlSetOnEvent(-1, "On_CleanHotkey")
    Local $p1HotkeyButton = GUICtrlCreateButton("p1", 120, 32, 81, 33)
        GUICtrlSetOnEvent(-1, "On_p1Hotkey")
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    Local $Group2 = GUICtrlCreateGroup("Gestion des positions de clics", 0, 88, 225, 89)
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    Local $Label1 = GUICtrlCreateLabel("à venir", 80, 128, 41, 20)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ### 
    
EndFunc

Func gui3()

    Local $Form3 = GUICreate("Raccourci de Clean")
        GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui3")
    Local $CleanHotkey = _GUICtrlHotkey_Create($Form3, 2, 2)
    _GUICtrlHotkey_SetRules($CleanHotkey, $HKCOMB_NONE, $HOTKEYF_ALT)
    _GUICtrlHotkey_SetHotkey($CleanHotkey, "")

    GUISetState()
    
    Local $SetCleanHotKeyButton = GUICtrlCreateButton("Set", 24, 32, 73, 33)
    GUICtrlSetOnEvent(-1, "On_SetCleanHotkey")
EndFunc

Func On_Close_Gui1()
    Exit
EndFunc

Func On_Close_Gui2()
    GUIDelete("[Owlolf] Options")
    GUICtrlSetState($g_idButton, $GUI_ENABLE)
EndFunc

Func On_Close_Gui3()
    GUIDelete("Raccourci de Clean")
    GUICtrlSetState($g_idButton2, $GUI_ENABLE)
EndFunc

Do you have any idea of why it happens ?

Thank you for your help.

Link to comment
Share on other sites

  • Moderators

Afaren,

You cannot use GUISetOnEvent to set a different function for each GUI's $GUI_EVENT_CLOSE event - the same event is fired whenever you press a [X]. What you need to do is set them all to the same function and then use @GUI_WinHandle to determine which GUI has sent the event:

Does this make it clearer:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $Form1, $Form2, $Form3, $Button1, $Button2, $Button3

gui1()
gui2()
gui3()

While 1
    Sleep(10)
WEnd

Func gui1()

    $Form1 = GUICreate("GUI 1", 237, 29, 1015, 0)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui")
    $Button1 = GUICtrlCreateButton("GUI 1 Button", 0, 0, 67, 25)
    GUICtrlSetOnEvent(-1, "On_Button")
    GUISetState(@SW_SHOW)

EndFunc   ;==>gui1

Func gui2()

    $Form2 = GUICreate("GUI 2", 228, 183, 1110, 109)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui")
    $Button2 = GUICtrlCreateButton("GUI 2 Button", 24, 32, 73, 33)
    GUICtrlSetOnEvent(-1, "On_Button")
    GUISetState(@SW_SHOW)

EndFunc   ;==>gui2

Func gui3()

    $Form3 = GUICreate("GUI 3")
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Gui")
    $Button3 = GUICtrlCreateButton("GUI 3 Button", 24, 32, 73, 33)
    GUICtrlSetOnEvent(-1, "On_Button")
    GUISetState(@SW_SHOW)

EndFunc   ;==>gui3

Func On_Close_Gui()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
        Case Else
            GUIDelete(@GUI_WinHandle)
    EndSwitch
EndFunc   ;==>On_Close_Gui

Func On_Button()

    Switch @GUI_CtrlId
        Case $Button1
            ConsoleWrite("GUI Button 1 pressed" & @CRLF)
        Case $Button2
            ConsoleWrite("GUI Button 2 pressed" & @CRLF)
        Case $Button3
            ConsoleWrite("GUI Button 3 pressed" & @CRLF)
    EndSwitch
EndFunc   ;==>On_Button

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Afaren,

Il n'y a pas de quoi.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...