Enable radio button after edit variable changes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mshall
Posts: 35
Joined: 13 Jul 2018, 16:42
Contact:

Enable radio button after edit variable changes

13 Jul 2018, 16:58

Hello,

I am trying to set up a radio button that is disabled until the user types something in the edit field. Even a timer would be acceptable in this case.

Current code:

Code: Select all

Gui, Add, Radio, x92 y139 w290 h30 altsubmit gCheck vRadioGroup , Default C:\User\My Documents
Gui, Add, Radio, x92 y209 w60 h30 altsubmit gCheck, Custom ;**** radio button that needs to be disabled
Gui, Add, Edit, x152 y209 w230 h30 vEditGroup, Type here 
Gui, Add, Button, x282 y289 w100 h30 +Disable , Submit

Check: ;radio button functions
gui, submit, nohide
if (RadioGroup = 1){
	IniWrite, %A_MyDocuments%, %A_MyDocuments%\setup.ini, FilePath, SetupPath
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
	}
else if (RadioGroup = 2){
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
}
The Submit button is set up just to change pages and act upon those file paths. As you can see I got Submit to disable and reenable (I think it just drew over it), but I can't figure the same for that radio button.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Enable radio button after edit variable changes

13 Jul 2018, 19:37

try

Code: Select all

Gui, Add, Radio, x92 y139 w290 h30 altsubmit gCheck vRadioGroup, Default C:\User\My Documents
Gui, Add, Radio, x92 y209 w60 h30 altsubmit gCheck vCustomRadio Disabled, Custom ;**** radio button that needs to be disabled
Gui, Add, Edit, x152 y209 w230 h30 vEditGroup gEnableRadio, Type here 
Gui, Add, Button, x282 y289 w100 h30 Disabled, Submit
Gui, Show
Return

Check: ;radio button functions
gui, submit, nohide
if (RadioGroup = 1){
	IniWrite, %A_MyDocuments%, %A_MyDocuments%\setup.ini, FilePath, SetupPath
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
	}
else if (RadioGroup = 2){
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
}

EnableRadio:
GuiControlGet, EditText,, EditGroup
if ( EditText != "Type here" && EditText != "" )
	GuiControl, Enable, CustomRadio
Else
	GuiControl, Disable, CustomRadio
return
also the option verb for gui controls is disabled ;)
User avatar
mshall
Posts: 35
Joined: 13 Jul 2018, 16:42
Contact:

Re: Enable radio button after edit variable changes

16 Jul 2018, 09:07

I tried the EnableRadio change, and that somehow broke my check function so I could no longer submit. I tried moving it before "Check" and when I select the radio button it exits the app. I played with submit a little bit, but it didn't seem to change. I then added an extra return to Check in case that was causing the failure. The GUI stopped exiting, but checking the radio button no longer writes to my setup.ini file (listed in Check).

My current code (including some stuff I didn't show before):

Code: Select all

Gui, Add, Text, x92 y79 w390 h30 , Please verify your AutoHotKey folder:
Gui, Add, Radio, x92 y139 w290 h30 altsubmit gCheck vRadioGroup , Default C:\User\My Documents ;radio size position name and functions which includes tags
Gui, Add, Radio, x92 y209 w60 h30 altsubmit gCheck vCustomRadio Disabled, Custom
Gui, Add, Edit, x152 y209 w230 h30 vEditGroup gEnableRadio, Type here ;a field to add text
Gui, Add, Button, x92 y289 w100 h30 , Cancel
Gui, Add, Button, x282 y289 w100 h30 Disabled , Submit
Gui, Tab, Step3
...
Return

EnableRadio:
GuiControlGet, EditText,, EditGroup
if ( EditText != "Type here" && EditText != "" )
	GuiControl, Enable, CustomRadio
Else
	GuiControl, Disable, CustomRadio
return ; https://autohotkey.com/boards/viewtopic.php?f=5&t=52015

;button section
Check: ;radio button functions
gui, submit, nohide
if (RadioGroup = 1){
	IniWrite, %A_MyDocuments%, %A_MyDocuments%\hotkey\autohotkey\setup.ini, FilePath, SetupPath
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
	}
else if (RadioGroup = 2){
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 , Submit
	return
}
return

ButtonCancel: 
ExitApp
return

ButtonSubmit:
;Still in progress regarding file paths
send ^{Tab}
if (RadioGroup = 2){
	IniWrite, %EditGroup%, %A_MyDocuments%\hotkey\autohotkey\setup.ini, FilePath, SetupPath
...
	return
	}
else {
	RunWait, %A_MyDocuments%\hotkey\autohotkey\GetRes.ahk, %A_MyDocuments%\hotkey\autohotkey ;tells the program to run the resolution finder. path should be updated
...
return
}
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Enable radio button after edit variable changes

16 Jul 2018, 13:28

Based on your original code with the EnableRadio label additon,
the variable RadioGroup returns 1 when the `Default` radio button is checked,
and 0 when the `Custom` radio button is checked.

To make both radio buttons write to the ini file, you will have to change the condition:
from if (RadioGroup = 1) to if ( RadioGroup = 1 || RadioGroup = 0 )
Or if you only want the `Custom` radio button to write the ini: if (RadioGroup = 0)


( not tested against your updated code ) htms..
User avatar
mshall
Posts: 35
Joined: 13 Jul 2018, 16:42
Contact:

Re: Enable radio button after edit variable changes  Topic is solved

18 Jul 2018, 17:01

Sorry for the late reply. It has taken me this long to fully understand what was needed.
I had too many variables for my radio buttons. It looks kind of ugly, but it appears to fully work now.

I changed it to look for radiodefault and radiocustom instead of just radiogroup.

1=true 0=false so the recommended solution wasn't perfect, but led me to the right path.
Thanks TLM!

solution code

Code: Select all

EnableRadio:
GuiControlGet, EditText,, EditGroup
if ( EditText != "Type here" && EditText != "" )
	GuiControl, -Disabled, RadioCustom
Else
	GuiControl, +Disabled, RadioCustom
return ; https://autohotkey.com/boards/viewtopic.php?f=5&t=52015

;button section
Click: ;radio button functions
gui, submit, nohide
if (RadioDefault = 1){
	IniWrite, %A_MyDocuments%, %A_MyDocuments%\hotkey\autohotkey\setup.ini, FilePath, SetupPath
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 -Disabled , Submit
	return
}
return

ClickEdit: ;radio button functions
gui, submit, nohide
if (RadioCustom = 1){
	Gui, Tab, Step2
	Gui, Add, Button, x282 y289 w100 h30 -Disabled , Submit
	return
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb and 305 guests