Jump to content

How to get value for Check Box from .ini


 Share

Recommended Posts

Below is the code I've used to add and retreive a vaule to a .ini file for a radio button, and it saves a value to the .ini, (saves checked as 1, unchecked as 4) but does not display the checkbox as ticked next time I open the GUI when is is saved as 1 in the .ini file.

I've used the same method for text fields in the same script and works fine. Do I have to do something different to handle checkbox data?

Get value from .ini if there (at top of script):

Global $PromoteSwitch = IniRead("settings.ini","promote","PromoteSwitch","")

Create check box with saved .ini setting:

$PromoteSwitch = GUICtrlCreateCheckbox ("", 32, 42, 10,10)
GUICtrlSetState($PromoteSwitch,$GUI_ACCEPTFILES)
GUICtrlSetData($PromoteSwitch,IniRead("settings.ini","promote","PromoteSwitch",""))

Write to .ini file (in a function near bottom of script)

IniWrite("settings.ini","promote","PromoteSwitch",GUICtrlRead($PromoteSwitch))

This is what gets written to the .ini file (checked)

PromoteSwitch=1

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

  • Developers

Try using :

GUICtrlSetState($PromoteSwitch,IniRead("settings.ini","promote","PromoteSwitch",""))

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sweet! thanks JdeB, that works fine!

I'm now having some trouble getting a combobox to do the same thing, as before it is writing to the .ini file but I'm not sure how to handle the combo box...

get data from .ini

Global $PromoteTime = IniRead("settings.ini","promote","PromoteTime","")

write combo... (at this stage just has a default set as I'm not sure how to get the combo box to display data from ini)

$PromoteTime =GUICtrlCreateCombo ("", 480,80,80,40)
GUICtrlSetData(-1,"1 Minute|5 Minutes|10 Minutes|15 Minutes|20 Minutes|25 Minutes|30 Minutes|35 Minutes|40 Minutes|45 Minutes|50 Minutes|55 Minutes|60 Minutes", "30 Minutes")
Edited by cyanidemonkey

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

  • Developers

Sweet! thanks JdeB, that works fine!

I'm now having some trouble getting a combobox to do the same thing, as before it is writing to the .ini file but I'm not sure how to handle the combo box...

get data from .ini

Global $PromoteTime = IniRead("settings.ini","promote","PromoteTime","")

write combo... (at this stage just has a default set as I'm not sure how to get the combo box to display data from ini)

$PromoteTime =GUICtrlCreateCombo ("", 480,80,80,40)
GUICtrlSetData(-1,"1 Minute|5 Minutes|10 Minutes|15 Minutes|20 Minutes|25 Minutes|30 Minutes|35 Minutes|40 Minutes|45 Minutes|50 Minutes|55 Minutes|60 Minutes", "30 Minutes")
Change the , "30 Minutes") to the value in the INI.....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks JdeB,

I thought it might be something like that, but when first replaced the default string with a .ini varible I broke it, got there in the end, still getting the hang of the AutoIt syntax...

Cheers for the help.

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...