how to display msgbox if checkbox is selected using editbox Topic is solved

Ask gaming related questions (AHK v1.1 and older)
KongKing
Posts: 76
Joined: 22 May 2022, 09:41

how to display msgbox if checkbox is selected using editbox

Post by KongKing » 22 May 2022, 17:28

Hey, can you tell me how to do with this code if I select 1 checkbox and choose a button, it will be displayed, e.g. msgbox, On1
and if you select 2 checkbox, another message will be , e.g. MsgBox 2 ? ? ? ? ?


CODE:

Code: Select all

Gui Font, s10 Bold, Arial
Gui Add, Text, x3 y1 w34 h23 +0x200, bind
Gui Font
Gui Add, Edit, gZapisz gstart x36 y3 w30 h21
Gui Font, s10 Bold, Arial
Gui Add, Text, x3 y80 w29 h23 +0x200, on1
Gui Font
Gui Add, CheckBox, von1 x30 y81 w17 h22
Gui Font, s10 Bold, Arial
Gui Add, Text, x3 y108 w27 h23 +0x200, on2
Gui Font
Gui Add, CheckBox, x31 y110 w19 h23

Gui Show, w322 h248, Window
Return







Zapisz:
Gui, Submit, NoHide
Hotkey, %start%, start
return



start:
if(on1 = 1)
{
MsgBox, On
}
if(on2 = 2)
MsgBox, On2
return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: how to display msgbox if checkbox is selected using editbox

Post by mikeyww » 22 May 2022, 20:40

Use a g-label.
A g-label such as gMySubroutine may be listed in the control's options. This would cause the MySubroutine label to be launched automatically whenever the user clicks or changes the checkbox.

KongKing
Posts: 76
Joined: 22 May 2022, 09:41

Re: how to display msgbox if checkbox is selected using editbox

Post by KongKing » 23 May 2022, 19:52

Hi! Really don't understand what to do, can you say more specific?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: how to display msgbox if checkbox is selected using editbox

Post by mikeyww » 23 May 2022, 20:08

See the link that I posted. It explains how the g-label works.

Code: Select all

Gui, Font, s10
Gui, Add, Text    , y10            , Bind:
Gui, Add, Text    , y+12           , On1:
Gui, Add, Text    , y+8            , On2:
Gui, Add, Hotkey  , ym      vhk
Gui, Add, CheckBox, gBoxes  von1
Gui, Add, CheckBox, gBoxes  von2
Gui, Add, Button  , xm w250 Default, OK
Gui Show,, Hotkey
Return

ButtonOK:
Gui, Submit
Hotkey, %hk%, Start, On
Return

Start:
MsgBox, Start
Return

Boxes:
Gui, Submit, NoHide
If on1
 MsgBox, On1
If on2
 MsgBox, On2
Return

KongKing
Posts: 76
Joined: 22 May 2022, 09:41

Re: how to display msgbox if checkbox is selected using editbox

Post by KongKing » 24 May 2022, 07:17

That's exactly what I meant, but not exactly how to do that when I click a button and I have no checkbox selected, nothing happens and if I select and only when I click the button, something will happen?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: how to display msgbox if checkbox is selected using editbox

Post by mikeyww » 24 May 2022, 07:31

This GUI has only one button. I am not following your description.

KongKing
Posts: 76
Joined: 22 May 2022, 09:41

Re: how to display msgbox if checkbox is selected using editbox

Post by KongKing » 24 May 2022, 07:38

If I click bind, it will say "Start" and I would like msgbox from the checkbox to be displayed when I click bind and select the checkbox

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: how to display msgbox if checkbox is selected using editbox  Topic is solved

Post by mikeyww » 24 May 2022, 08:07

Adjust as needed.

Code: Select all

Gui, Font, s10
Gui, Add, Text    , y10 , Bind:
Gui, Add, Text    , y+12, On1:
Gui, Add, Text    , y+8 , On2:
Gui, Add, Hotkey  , ym    vhk
Gui, Add, CheckBox,       von1
Gui, Add, CheckBox,       von2
Gui, Add, Button  , xm    w250 Default, Bind
Gui Show,, Hotkey
Return

ButtonBind:
Try Hotkey, %hk%, Boxes, Off
Gui, Submit, NoHide
Try Hotkey, %hk%, Boxes, On
Catch
 Return
MsgBox, 64, Start, Start!
started := True
Boxes:
If !started
 Return
Gui, Submit, NoHide
If on1
 MsgBox, On1
If on2
 MsgBox, On2
Return

KongKing
Posts: 76
Joined: 22 May 2022, 09:41

Re: how to display msgbox if checkbox is selected using editbox

Post by KongKing » 24 May 2022, 09:00

Thank you brother for your help, everything works

Post Reply

Return to “Gaming Help (v1)”