How do I: Pass a button label as a variable?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tecdragon
Posts: 14
Joined: 31 Aug 2020, 10:22

How do I: Pass a button label as a variable?

Post by tecdragon » 31 Aug 2020, 10:28

Trying to pass the button label as the variable to capture in a msgbox at the end. I googled it but not having much luck, help?

Code: Select all

Sizes:
Gui,2: Destroy
Gui,3: Show, w800 h600, Sizes
Gui,3: Add, Button, x13 y71 w125 h125 gSize, &Small
Gui,3: Add, Button, x166 y71 w125 h125 gSize, &Medium
Return

Size:
Gui,3: Submit
Size = % Size
GoSub, Final
Return
 
 Final:
 Msgbox, % Size
 return
 

User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: How do I: Pass a button label as a variable?

Post by TheDewd » 31 Aug 2020, 12:30

Code: Select all

Msgbox, % A_GuiControl

tecdragon
Posts: 14
Joined: 31 Aug 2020, 10:22

Re: How do I: Pass a button label as a variable?

Post by tecdragon » 31 Aug 2020, 16:46

Still need some help, that got me closer but it doesn't seem to store the variable as the selected size. I can't call on %Size% in a different function and have it return the selected value. How?

Code: Select all

Sizes:
Gui,2: Destroy
Gui,3: Show, w800 h600, Sizes
Gui,3: Add, Button, x13 y71 w125 h125 gSize, Small
Gui,3: Add, Button, x166 y71 w125 h125 gSize, Medium
Return

Size:
Gui,3: Submit
Size = % A_GuiControl
GoSub, Final
Return

Final:
msgbox, % Size
Return
Last edited by tecdragon on 31 Aug 2020, 16:56, edited 1 time in total.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How do I: Pass a button label as a variable?

Post by BoBo » 31 Aug 2020, 16:56

Size = % A_GuiControl > Size := A_GuiControl :yawn:

Post Reply

Return to “Ask for Help (v1)”