V2....128 ... TestGui Topic is solved

Report problems with documented functionality
HugoM
Posts: 37
Joined: 06 Mar 2018, 14:21

V2....128 ... TestGui

Post by HugoM » 10 Mar 2021, 08:51

Moin,
I try to transfer some Guis to be started with Hotkeys from V1x to V2...128. The example from docs works. But when I uncomment the Hotkey ^b nothing happens when I press ctrl+b. Same with other hotkeys. e.g. !g. What am i doing wrong?
Stay healthy

Code: Select all

; ^b::
{
	MyGui := Gui(, "Simple Input Example")
	MyGui.Add("Text",, "First name:")
	MyGui.Add("Text",, "Last name:")
	MyGui.Add("Edit", "vFirstName ym")  ; The ym option starts a new column of controls.
	MyGui.Add("Edit", "vLastName")
	MyGui.Add("Button", "default", "OK").OnEvent("Click", (*) => ProcessUserInput(MyGui))
	MyGui.OnEvent("Close", ProcessUserInput)
	MyGui.Show()

	ProcessUserInput(thisGui, *)
	{
		Saved := thisGui.Submit()  ; Save the contents of named controls into an object.
		MsgBox("You entered '" Saved.FirstName " " Saved.LastName "'.")
	}
}

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: V....128 ... TestGui

Post by swagfag » 10 Mar 2021, 09:19

unnamed hotkeys with closures in them are kinda buggy right now, see https://www.autohotkey.com/boards/viewtopic.php?f=14&t=87863
to fix:
  • name ur hotkey, eg:

    Code: Select all

    ^b::
    control_b(ThisHotkey) {
    ...
    ...
  • dont create closures in them:

    Code: Select all

    ^b::
    {
    	MyGui := Gui(, "Simple Input Example")
    	MyGui.Add("Text",, "First name:")
    	MyGui.Add("Text",, "Last name:")
    	MyGui.Add("Edit", "vFirstName ym")  ; The ym option starts a new column of controls.
    	MyGui.Add("Edit", "vLastName")
    	MyGui.Add("Button", "default", "OK").OnEvent("Click", ProcessUserInput.Bind(MyGui))
    	MyGui.OnEvent("Close", ProcessUserInput)
    	MyGui.Show()
    
    	ProcessUserInput(thisGui, *)
    	{
    		Saved := thisGui.Submit()  ; Save the contents of named controls into an object.
    		MsgBox("You entered '" Saved.FirstName " " Saved.LastName "'.")
    	}
    }
    or

    Code: Select all

    #Requires AutoHotkey v2.0-a128-f63b0eb4
    ^b::
    {
    	MyGui := Gui(, "Simple Input Example")
    	MyGui.Add("Text",, "First name:")
    	MyGui.Add("Text",, "Last name:")
    	MyGui.Add("Edit", "vFirstName ym")  ; The ym option starts a new column of controls.
    	MyGui.Add("Edit", "vLastName")
    	MyGui.Add("Button", "default", "OK").OnEvent("Click", ProcessUserInput)
    	MyGui.OnEvent("Close", ProcessUserInput)
    	MyGui.Show()
    
    	ProcessUserInput(this, *)
    	{
    		if (this is Gui.Control) ; if the Button(or any other Control) was passed in
    			this := this.Gui ; get the Gui object, the control belongs to, instead
    
    		Saved := this.Submit()  ; Save the contents of named controls into an object.
    		MsgBox("You entered '" Saved.FirstName " " Saved.LastName "'.")
    	}
    }

HugoM
Posts: 37
Joined: 06 Mar 2018, 14:21

Re: V2....128 ... TestGui

Post by HugoM » 10 Mar 2021, 13:51

Great, thank you.
I think I will (what I unfortunately forgot, but knew) name my hotkeys and use the code for 128.
Stay healthy and turn the key here.

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: V2....128 ... TestGui  Topic is solved

Post by lexikos » 13 Mar 2021, 22:35

Fixed by v2.0-a129.

Post Reply

Return to “Bug Reports”