Page 1 of 1

The Mystery of Gui Name

Posted: 24 Jun 2021, 02:12
by SolihullRog
As a real noobie, and completely confused by the AutoHotkey documentation, could I please ask a very simple question.
The definition of Gui New mentions GuiName:New. This seems very sensible, logical, and necessary for a script which might contain more than one gui.
But that seems to be the only reference to GuiName anywhere. I would expect it to appear within Gui Add and Gui Show at the very least.
What am I missing?

Re: The Mystery of Gui Name

Posted: 24 Jun 2021, 02:27
by swagfag
what is the question?

https://www.autohotkey.com/docs/commands/Gui.htm#MultiWin has usage examples

Re: The Mystery of Gui Name

Posted: 24 Jun 2021, 02:41
by SolihullRog
Hi,
Thanks for your remarkably speedy response.
My question was "Am I going stupid, or is the official documentation not fit for purpose?"
Your response provides a clear answer. I'm going stupid - I should have read the 10,000 words of that page before progressing with my script.

Re: The Mystery of Gui Name

Posted: 24 Jun 2021, 05:00
by Hellbent
Simple advice. If you aren't 100% sure about what you are doing, use the name everywhere it can be used.

That way you NEVER have a problem like this.


Press the hotkey (Numpad1)

Code: Select all

#SingleInstance, Force

Gui, 2:New 
Gui, Add, Button, xm ym w380 gButton1Press, Change this text
Gui, Show, w400 h400, Gui 2

Gui, 3:New, +Owner2
Gui, Add, Button, xm ym w180 gButton2Press , Change this text
Gui, Show, w200 h200, Gui 3

return
3GuiClose:
2GuiClose:
*ESC::ExitApp

Button1Press:
	GuiControl,,Button1, Gui 2
	return


;*********************************************************************************************************************************
;If this thread is launched by pressing the button on gui 3 everything works as expected and the name will be assumed ("3").
;if the thread is launched by pressing the hotkey all bets are off (will assume you mean gui 1)
;*********************************************************************************************************************************

Numpad1::   ;<<<<<-------- Press this hotkey and see if the button changes on the small gui
Button2Press:
	GuiControl,,Button1, Gui 3????
	
	;In this case you should type it like this
	;~ GuiControl,3:,Button1, Gui 3????
	return