How to identify the current GUI default window? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
afe
Posts: 578
Joined: 06 Dec 2018, 04:36

How to identify the current GUI default window?

08 Apr 2019, 05:41

Hello,

When the child GUI window is destroyed, which one is the current default window?

In the following example, when the Close button of the child window is clicked, the child window is destroyed, but at this time, the parent window GUI1 does not seem to be the default window.

Then, after the ButtonClose subroutine is executed, will GUI1 become the default window, or will GUI1 become the default window only after the GUI1 window is activated (such as clicking)?


Code: Select all

Gui, Add, Text, w200 vGui_1
Gui, Add, Button, x0, Open
Gui, Show, h100 w200
return

ButtonOpen:
Gui, 1:+Disabled
Gui, 2:Default
Gui, +Owner1
Gui, Add, Button,, Close
Gui, Show, h50 w100
return

2ButtonClose:
Gui, 1:-Disabled
Gui, 2:Destroy
; Gui, 1:Default
GuiControl, Text, Gui_1, TEST
return
Last edited by afe on 08 Apr 2019, 13:20, edited 1 time in total.
User avatar
lvalkov
Posts: 38
Joined: 08 Mar 2019, 16:39

Re: How to identify the current GUI default window?

08 Apr 2019, 11:33

Gui Destroy does not alter defaultness in any way, shape or form. It merely deletes the specified GUI. To find out what the default GUI for a given thread is, inspect A_DefaultGui. It will be 2 in your case, since Gui, 2:Default is the last instruction that changed it and given that your first button subroutine lacks a Return statement, the next subroutine immediately beneath it is executed. I am not even sure whether this is how you originally intended the code to flow. Regardless, the default GUI for the subroutine 2ButtonClose:, had you clicked the button, would have been 2 anyway, since clicking it internally sets the button thread's default GUI to the GUI containing the button.
afe
Posts: 578
Joined: 06 Dec 2018, 04:36

Re: How to identify the current GUI default window?

08 Apr 2019, 13:31

Due to negligence, I dropped the return and I have added it.

This means that even though GUI2 has been destroyed, it is still the default window.

After GUI2 is destroyed, GUI1 will not become the default window until the mouse clicks on the GUI1 window.

Is this correct?
User avatar
lvalkov
Posts: 38
Joined: 08 Mar 2019, 16:39

Re: How to identify the current GUI default window?  Topic is solved

09 Apr 2019, 14:22

No. Clicking on the GUI1 window doesn't affect which GUI is the default one. Unless, of course, you're talking about clicking the button labeled "Close", belonging to GUI1, in which case, yes, the default GUI for the "Close" button thread will be set to GUI1. I've already explained this interaction in my previous post.
afe
Posts: 578
Joined: 06 Dec 2018, 04:36

Re: How to identify the current GUI default window?

04 Jul 2019, 12:24

Thank you very much for your explanation, now I finally understand.

Return to “Ask For Help”

Who is online

Users browsing this forum: agrout, Bing [Bot], Google [Bot] and 212 guests