The Mystery of Gui Name

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SolihullRog
Posts: 7
Joined: 29 Jun 2018, 11:48

The Mystery of Gui Name

24 Jun 2021, 02:12

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?
SolihullRog
Posts: 7
Joined: 29 Jun 2018, 11:48

Re: The Mystery of Gui Name

24 Jun 2021, 02:41

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.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: The Mystery of Gui Name

24 Jun 2021, 05:00

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Exies, Google [Bot], JoeWinograd, scriptor2016 and 101 guests