Page 1 of 1

Hide all GUIs in one line

Posted: 13 Apr 2018, 08:31
by jaccotjuhhh
Hello people of the internet.

I am developing a script which will contain tens of small GUIs. And i will be adding more over time.
However, when i am done with going through the different GUIs, i want to return to my main menu.
The issue i'm having is, is being able to hide all the GUIs at once, and show the main menu again.
At this moment i have a line for every GUI, to hide. But i would have to maintain that by adding the new GUIs, and it takes up a lot of space.
So, is it possible to hide all GUIs in one line? Almost like a

Code: Select all

GUI *:hide
.

If the above isn't clear, here's an example code i have going

Code: Select all

M9:
Gui M9:Show, x3635 y850 w200 h200, M9
Return
M8:
Gui M8:Show, x3635 y850 w200 h200, M8
Return
M7:
Gui M7:Show, x3635 y850 w200 h200, M7
Return
M6:
Gui M6:Show, x3635 y850 w200 h200, M6
Return
M5:
Gui M5:Show, x3635 y850 w200 h200, M5
Return

CloseMGUI:
;
;here goes the close all gui codes
;
Return

Re: Hide all GUIs in one line

Posted: 13 Apr 2018, 12:02
by MaxAstro
If the guis have predictable names, you should be able do something like this:

Code: Select all

Loop, 20
	GUI M%A_Index%:hide

Re: Hide all GUIs in one line

Posted: 13 Apr 2018, 14:52
by garry
an example

Code: Select all

;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=47239 ---

tot:=10
gui 20: default
Gui 20: add,button, x10  y10 w100 h26 gShowAll,ShowAllGui
Gui 20: add,button, x120 y10 w100 h26 gHideAll,HideAllGui
Gui 20: show
return

showall:
x:=5
loop,%tot%
  {
  Gui m%a_index%:show,x%x% y10 w170 h100,m%a_index%
  x:=(x+180)
  }
return

20Guiclose:
Loop,%tot%
  GUI M%A_Index%:destroy
exitapp

HideAll:
Loop,%tot%
  GUI M%A_Index%:hide
return

Re: Hide all GUIs in one line

Posted: 13 Apr 2018, 23:48
by hunter99
Hi jaccotjuhhh, try using this command:

From the docs.
GroupAdd, GroupName [, WinTitle, WinText, Label, ExcludeTitle, ExcludeText]
;===========================================
;for this example I used "allguis" as the GroupName
;May not need the Global in the gui1_hwnd and gui2_hwnd variables.

;-----------------------------------------------------
;Put this in the first Gui:

Global gui1_hwnd := WinExist()
GroupAdd, allguis, ahk_id %gui1_hwnd%
;-------------------------------------------------------
;Put this in the second Gui:

Global gui2_hwnd := WinExist()
GroupAdd, allguis, ahk_id %gui2_hwnd%
;--------------------------------------------------
;Here is your Hide and Show:

WinHide, ahk_group allguis

WinShow, ahk_group allguis
;=================================

hunter99