Checked Radio Won't Update GUI Winset Transparent Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iluvurmovies
Posts: 3
Joined: 06 Jul 2019, 19:41

Checked Radio Won't Update GUI Winset Transparent

06 Jul 2019, 20:34

Apologies if the subject doesn't make sense but I was trying to be succinct.

Trying to Solve for:
I want users to be able to save transparency preferences and have their saved preference update the GUI upon launch from the saved ini file

Issue:
the "checked" state of the radios i'm using for the different transparency options will update visibly and show the right radio is selected but it won't update the associated "winset transparent" setting for the GUI

Things I've tried:
Too many to remember. :-) Because I am pulling the "checked" state from an ini file I am using a variable to enter "checked" into the script upon loading. So, I thought that may be the issue but even if I hard set "checked" in the script it won't update the "winset transparent" settings. I've tried different means to parse the current state and apply winset after the iniread but nothing seems to work. Hopefully it something simple I'm missing.


;Here's how I'm pulling from the ini and updating checked state:

IniRead, Trans1, ProfileSettings.ini, Settings, Trans1, 0

IniRead, Trans2, ProfileSettings.ini, Settings, Trans2, 0

IniRead, Trans3, ProfileSettings.ini, Settings, Trans3, 0

IniRead, Trans4, ProfileSettings.ini, Settings, Trans4, 0

IniRead, Trans5, ProfileSettings.ini, Settings, Trans5, 0

IniRead, Trans6, ProfileSettings.ini, Settings, Trans6, 0

IniRead, Trans7, ProfileSettings.ini, Settings, Trans7, 0


Loop 7
{
If (Trans%A_Index% = 1)
Trans%A_Index% = Checked

else
Trans%A_Index% =

}

Gui,Main: Add, Radio, x5 y160 %Trans1% Group vTrans1 gTransSet, 0
Gui,Main: Add, Radio, x45 y160 %Trans2% vTrans2 gTransSet, 10
Gui,Main: Add, Radio, x5 y183 %Trans3% vTrans3 gTransSet, 25
Gui,Main: Add, Radio, x45 y183 %Trans4% vTrans4 gTransSet, 35
Gui,Main: Add, Radio, x5 y206 %Trans5% vTrans5 gTransSet, 50
Gui,Main: Add, Radio, x45 y206 %Trans6% vTrans6 gTransSet, 60
Gui,Main: Add, Radio, x5 y229 %Trans7% vTrans7 gTransSet, 75


;Here's the label I have attached to the radio group and it function fine as long as i'm manually selecting the radio
TransSet:
Gui, Submit, NoHide
If(Trans1==1)
Winset, Transparent, 255
else if(Trans2==1)
Winset, Transparent, 230
else if(Trans3==1)
Winset, Transparent, 200
else if(Trans4==1)
Winset, Transparent, 166
else if(Trans5==1)
Winset, Transparent, 136
else if(Trans6==1)
Winset, Transparent, 102
else if(Trans7==1)
Winset, Transparent, 72
return

I've even tried having a version this label run after the iniread is completed but it still doesn't update the current GUI state. Thanks for any help you can provide and I'm a bit of a novice on autohotkey so if you can provide example scripts it would be great.

Thank you
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Checked Radio Won't Update GUI Winset Transparent

06 Jul 2019, 21:44

I added a line before your block, and three lines after. Is that what you are after?

Code: Select all

Gui, Main: New, HWNDhGui
Gui,Main: Add, Radio, x5 y160 %Trans1% Group vTrans1 gTransSet, 0
Gui,Main: Add, Radio, x45 y160 %Trans2% vTrans2 gTransSet, 10
Gui,Main: Add, Radio, x5 y183 %Trans3% vTrans3 gTransSet, 25
Gui,Main: Add, Radio, x45 y183 %Trans4% vTrans4 gTransSet, 35
Gui,Main: Add, Radio, x5 y206 %Trans5% vTrans5 gTransSet, 50
Gui,Main: Add, Radio, x45 y206 %Trans6% vTrans6 gTransSet, 60
Gui,Main: Add, Radio, x5 y229 %Trans7% vTrans7 gTransSet, 75
Gui,Main: Show
Winset, Transparent, 166, ahk_id %hGui%
return
checked with/against:

Code: Select all

[Settings]
Trans1=0
Trans2=0
Trans3=0
Trans4=1
Trans5=0
Trans6=0
Trans7=0
This solves for single Value Trans4, but should get you started.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Checked Radio Won't Update GUI Winset Transparent

06 Jul 2019, 22:01

second attempt: makes use of your "falling through" setup:
just one line added to the brginning of the block:

Code: Select all

Gui, Main: New, +LastFound
Gui,Main: Add, Radio, x5 y160 %Trans1% Group vTrans1 gTransSet, 0
Gui,Main: Add, Radio, x45 y160 %Trans2% vTrans2 gTransSet, 10
; ...
should work for all Values, only ittle tested
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Checked Radio Won't Update GUI Winset Transparent

06 Jul 2019, 23:03

last improvement: get rid of New. not needed. without it, you can easily move my line to between the blocks.
only thing your missing is this: GuiThreads get LastFound window set automatically, AHK does it for us.
Falling into the same procedure, AHK does not set the LastFound window, we do it ourselves.

Code: Select all

; ...
Gui,Main: Add, Radio, x45 y206 %Trans6% vTrans6 gTransSet, 60
Gui,Main: Add, Radio, x5 y229 %Trans7% vTrans7 gTransSet, 75
Gui,Main: Show
Gui, Main: +LastFound

; falling through

;Here's the label I have attached to the radio group and it function fine as long as i'm manually selecting the radio
TransSet:
; ...
iluvurmovies
Posts: 3
Joined: 06 Jul 2019, 19:41

Re: Checked Radio Won't Update GUI Winset Transparent

06 Jul 2019, 23:29

Thanks for the reply but unfortunately neither of these seem to be doing what I'm looking for. I'll describe a little more about the GUI i'm building and the function I'm looking for and see if you have any other thoughts.

-The tool is basically a data compiler both from manual edit fields and dropdownlists
- I have a separate "Preferences" tab where the user can select radio buttons for transparency, color, and alwaysontop
- I want the user to be able to select the radio buttons associated to there preferred transparency level, color, and/or always on top then save it and have those preferences load back up when they open the GUI again
- I have it built up to the point where the current state of radio button will save to ini file but loading it back in is where it's getting tripped up

When it loads back in it will visibly change which radio is selected but nothing actually changes on the GUI's appearance. I also have some edit boxes that are performing a similar task and they're working fine. It's just the radios that are killing me.

Thanks again for trying to help
iluvurmovies
Posts: 3
Joined: 06 Jul 2019, 19:41

Re: Checked Radio Won't Update GUI Winset Transparent  Topic is solved

07 Jul 2019, 00:12

Thanks again Wolf but I figured it out. What you said got me thinking about it a little bit differently and got me to the resolution. I had to add another Gui Show above another winset if else that looked for the updated state after the iniread. It was simple in the end but isn't it always. Here's the section of the code if your interested....it's not the whole thing because that to much but it's the important bit.

Gui,Main: Add, Edit, x5 y56 w100 vAgentName gSubmit_All
Gui,Main: Add, Edit, x5 y102 w40 vAgentInitials gSubmit_All

Gui,Main: Add, Text, x5 y137 vSetTransTxt, Set Transparency Percentage:

IniRead, Trans1, ProfileSettings.ini, Settings, Trans1, 0

IniRead, Trans2, ProfileSettings.ini, Settings, Trans2, 0

IniRead, Trans3, ProfileSettings.ini, Settings, Trans3, 0

IniRead, Trans4, ProfileSettings.ini, Settings, Trans4, 0

IniRead, Trans5, ProfileSettings.ini, Settings, Trans5, 0

IniRead, Trans6, ProfileSettings.ini, Settings, Trans6, 0

IniRead, Trans7, ProfileSettings.ini, Settings, Trans7, 0


Loop 7
{
If (Trans%A_Index% = 1)
Trans%A_Index% = Checked

else
Trans%A_Index% =

}


Gui,Main: Add, Radio, x5 y160 %Trans1% Group vTrans1 gTransSet, 0
Gui,Main: Add, Radio, x45 y160 %Trans2% vTrans2 gTransSet, 10
Gui,Main: Add, Radio, x5 y183 %Trans3% vTrans3 gTransSet, 25
Gui,Main: Add, Radio, x45 y183 %Trans4% vTrans4 gTransSet, 35
Gui,Main: Add, Radio, x5 y206 %Trans5% vTrans5 gTransSet, 50
Gui,Main: Add, Radio, x45 y206 %Trans6% vTrans6 gTransSet, 60
Gui,Main: Add, Radio, x5 y229 %Trans7% vTrans7 gTransSet, 75




Gui,Main: Add, Button, x465 y545 w50 h20 vSaveProfile gSave_Profile,SAVE



Load_Profile:
Gui, Submit, NoHide
IniRead, AgentName, ProfileSettings.ini, Settings, AgentName
GuiControl,Main:,AgentName, %AgentName%
IniRead, AgentInitials, ProfileSettings.ini, Settings, AgentInitials
GuiControl,Main:,AgentInitials, %AgentInitials%
Gui,Main: Show, w525 h575, LNP Notes ver1.0
If(Trans1==1)
Winset, Transparent, 255, LNP Notes ver1.0
else if(Trans2==1)
Winset, Transparent, 230, LNP Notes ver1.0
else if(Trans3==1)
Winset, Transparent, 200, LNP Notes ver1.0
else if(Trans4==1)
Winset, Transparent, 166, LNP Notes ver1.0
else if(Trans5==1)
Winset, Transparent, 136, LNP Notes ver1.0
else if(Trans6==1)
Winset, Transparent, 102, LNP Notes ver1.0
else if(Trans7==1)
Winset, Transparent, 72, LNP Notes ver1.0
Return


Save_Profile:
Gui, Submit, NoHide
IniWrite, %AgentName%, ProfileSettings.ini, Settings, AgentName
IniWrite, %AgentInitials%, ProfileSettings.ini, Settings, AgentInitials
IniWrite, %Trans1%, ProfileSettings.ini, Settings, Trans1
IniWrite, %Trans2%, ProfileSettings.ini, Settings, Trans2
IniWrite, %Trans3%, ProfileSettings.ini, Settings, Trans3
IniWrite, %Trans4%, ProfileSettings.ini, Settings, Trans4
IniWrite, %Trans5%, ProfileSettings.ini, Settings, Trans5
IniWrite, %Trans6%, ProfileSettings.ini, Settings, Trans6
IniWrite, %Trans7%, ProfileSettings.ini, Settings, Trans7
return


Thanks again

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], peter_ahk and 359 guests