Show name of checkbox button

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 324
Joined: 21 Aug 2016, 05:11

Show name of checkbox button

26 Oct 2016, 05:28

Hi,
I need something very simple,
what ever you choose "Msg1" or "Msg2" it will popup a msg with the name of the checkbox button.

For example:
If I choose "Msg2" and Click "OK",
I will get a msg with "Msg2". (coz is the name of the checkbox button)

what "variable" should I use ?

Thanks!

Code: Select all

#SingleInstance force
#NoEnv
SetWorkingDir %A_ScriptDir%

Gui Add, CheckBox, x15 y18 w120 h23, Msg1
Gui Add, CheckBox, x16 y54 w120 h23, Msg2
Gui Add, Button, x128 y34 w75 h23, OK
Gui Show, w217 h97
Return



GuiEscape:
GuiClose:
    ExitApp

; End of the GUI section
User avatar
TLM
Posts: 1589
Joined: 01 Oct 2013, 07:52
GitHub: TLMcode
Contact:

Re: Show name of checkbox button

26 Oct 2016, 05:40

Quick and dirty approach ( there's more than one way ):

Code: Select all

Gui Add, CheckBox, x15 y18 w120 h23 vMsg1 gAssignMsg, Msg1
Gui Add, CheckBox, x16 y54 w120 h23 vMsg2 gAssignMsg, Msg2
Gui Add, Button, x128 y34 w75 h23 gDisplayMsg, OK
Gui Show, w217 h97
Return

AssignMsg:
CurrentMsg := A_GuiControl
Return

DisplayMsg:
ToolTip % CurrentMsg
Return

GuiEscape:
GuiClose:
    ExitApp
User avatar
Tomer
Posts: 324
Joined: 21 Aug 2016, 05:11

Re: Show name of checkbox button

26 Oct 2016, 06:54

Thanks but it doesn't take the name from the name text itself,
it take it from the "v-var",

is it possible to take it from the text name itself ?

Thanks
ahkForWork
Posts: 92
Joined: 28 Mar 2016, 07:59

Re: Show name of checkbox button

26 Oct 2016, 07:01

The way TLM did is the only way that will work.
User avatar
Tomer
Posts: 324
Joined: 21 Aug 2016, 05:11

Re: Show name of checkbox button

26 Oct 2016, 07:20

Ok thank you very much!

last:
is it possible to show it only when the checkbox is checked ? if the 2 checkboxs are checked show the names in one msgbox,
etc etc

tnx
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Show name of checkbox button

26 Oct 2016, 08:33

Try this:

Code: Select all

#NoEnv
#SingleInstance, Force

Gui, Add, CheckBox, x15 y18 w100 h23, Msg1
Gui, Add, CheckBox, x16 y54 w100 h23, Msg2
Gui, Add, Button, x128 y34 w75 h23, OK
Gui, Show, w217 h97
Return


ButtonOK:
    Gui, +LastFound
    GuiControlGet, CHK_1,, Button1
    ControlGetText, TXT_1, Button1
    GuiControlGet, CHK_2,, Button2
    ControlGetText, TXT_2, Button2
    MsgBox, % (CHK_1 ? TXT_1 : "") "`n"
            . (CHK_2 ? TXT_2 : "") "`n"
Return


GuiEscape:
GuiClose:
ExitApp
I hope that helps.
User avatar
Tomer
Posts: 324
Joined: 21 Aug 2016, 05:11

Re: Show name of checkbox button

27 Oct 2016, 04:34

Thanks Wolf, works gr8

Return to “Ask For Help”

Who is online

Users browsing this forum: JAutohotkey, thebat and 40 guests