Jump to content

IniWrite problem


Bert
 Share

Recommended Posts

I got a head scratcher here. If I use the default path, I can write to the ini file. If I choose any other path, I get a error saying the file is read only. I put in a msgbox to test to see what was happening, and that is what I have been able to figure out.

The problem is with line 218.

here is the code:

CODE

#region

#include <GUIConstants.au3>

;GUISetHelp("config\help.hlp")

$Woption = GUICreate("Options", 450,360)

$Wbutton1 = GUICtrlCreateButton("Apply", 250, 315, 60, 25)

$Wbutton2 = GUICtrlCreateButton("Close", 340, 315, 60, 25)

#endregion

#region ;logon ---------------------------------------------------------------- working

$Wgroup1 = GUICtrlCreateGroup("Logon settings",10, 7, 195, 106)

$Wlgini1 = iniread("config\config.ini", "Config", "ID_RUNAS", "0")

$Wlogon1 = GUICtrlCreatecheckbox("Save logon ID for RunAs", 15, 25)

GUICtrlSetState($Wlogon1, $Wlgini1)

$Wlgini2 = iniread("config\config.ini", "Config", "ID_AUTOLOGON", "0")

$Wlogon2 = GUICtrlCreatecheckbox("Save logon ID for AutoLogon", 15, 45)

GUICtrlSetState($Wlogon2, $Wlgini2)

$Wlgini3 = iniread("config\config.ini", "Config", "DOMAIN_RUNAS", "0")

$Wlogon3 = GUICtrlCreatecheckbox("Save Domain name for RunAs", 15, 65)

GUICtrlSetState($Wlogon3, $Wlgini3)

$Wlgini4 = iniread("config\config.ini", "Config", "DOMAIN_AUTOLOGON", "0")

$Wlogon4 = GUICtrlCreatecheckbox("Save Domain name for AutoLogon", 15, 85)

GUICtrlSetState($Wlogon4, $Wlgini4)

#endregion ;this section is working

#region ;alarm ---------------------------------------------------------------- bug: displays message "1" if no file is selected.

$Wgroup2 = GUICtrlCreateGroup("Alarm settings",215, 7, 225, 106)

$inialarm1 = iniread("config\config.ini", "Config", "ALARM_CFG", "1") ;checkbox on or off

$inialarm2 = Iniread("config\config.ini", "Config", "Alarm_sound", @WindowsDir &"\media\chord.wav")

$inialarm3 = iniread("config\config.ini", "Config", "ALARM_TYPE", "3")

$Walarm1 = GUICtrlCreatecheckbox("", 220, 25, -1, 20) ;when checked, it will enable $Walarm1

$Walarm2 = GUICtrlCreateinput("", 243, 25, 155, 18, $ES_AUTOHSCROLL+$ES_READONLY) ;file path

$Walarm3 = GUICtrlCreatebutton(" . . . ", 405, 25, 25, 18 ) ;folder selector

if $inialarm1 == 1 then _alarmC1()

if $inialarm1 == 0 then _alarmC2()

GUICtrlSetTip($Walarm1, " If this box is checked, you"& @CRLF &"can select what sound you"& @CRLF &" wish to use for a alarm.")

;----------------------------

$Walarm4 = GUICtrlCreateradio("Notify and Exit as default", 220, 45, 155)

$Walarm5 = GUICtrlCreateradio("Alarm then Return as default", 220, 65, 155)

$Walarm6 = GUICtrlCreateradio("No default", 220, 85, 155)

if $inialarm3 == 1 then GUICtrlSetState($Walarm4, $GUI_CHECKED)

if $inialarm3 == 2 then GUICtrlSetState($Walarm5, $GUI_CHECKED)

if $inialarm3 == 3 then GUICtrlSetState($Walarm6, $GUI_CHECKED)

#endregion

#region ;log file ------------------------------------------------------------- working

$Wgroup3 = GUICtrlCreateGroup("Log file location",10, 120, 195, 90)

$inilog1 = Iniread("config\config.ini", "Config", "LOGPATH", EnvGet('SystemDrive'))

$inilog2 = iniread("config\config.ini", "Config", "LOGTYPE", 4)

$INILOG3 = iniread("config\config.ini", "Config", "LOG_ALWAYS", 4)

$INILOG4 = iniread("config\config.ini", "Config", "CENTRAL_LOGGING", 1)

$Wlog1 = GUICtrlCreatebutton(" . . . ", 175, 140, 25, 18) ;button for folder

$Wlog2 = GUICtrlCreateinput("", 35 ,140, 135, 18, $ES_AUTOHSCROLL+$ES_READONLY)

$Wlog3 = GUICtrlCreatecheckbox("", 15, 140, -1, 20) ;when checked, it will ungray the input box, and folder button

if $inilog2 == 1 then _logC1()

if $inilog2 == 4 then _logC2()

GUICtrlSetTip($Wlog3, "If this box is checked, you"& @CRLF &"can select the path you wish"& @CRLF &"to use for storing the log file.")

$Wlog4 = GUICtrlCreatecheckbox("Always log", 15, 160, 120, 20) ;turns on logging always

GUICtrlSetTip($Wlog4, "If checked, this will save a log of what was ran on"& @CRLF &"the PC by ScriptLoader, including any activation"& @CRLF &"keys entered.")

IF $INILOG3 = 1 then GUICtrlSetState($Wlog4, $GUI_CHECKED)

IF $INILOG3 = 4 then GUICtrlSetState($Wlog4, $GUI_UNCHECKED)

$Wlog5 = GUICtrlCreatecheckbox("Central Logging", 15, 180, 120, 20) ;turns on logging always

GUICtrlSetTip($Wlog5, "This will save copies of log files to /Config/C_log."& @CRLF &"If ALWAYS LOG is checked, it will simply make a"& @CRLF &"extra copy of the log file that is created on the"& @CRLF &"PC when ScriptLoader is ran.")

IF $INILOG4 = 1 then GUICtrlSetState($Wlog5, $GUI_CHECKED)

IF $INILOG4 = 4 then GUICtrlSetState($Wlog5, $GUI_UNCHECKED)

#endregion

#region ;Reboot --------------------------------------------------------------- working

$Wgroup4 = GUICtrlCreateGroup("Reboot",215, 120, 225,75)

$inireboot1 = iniread("config\config.ini", "Config", "REBOOTTIMER", "15")

$inireboot2 = iniread("config\config.ini", "Config", "REBOOTALWAYS", "4")

$Wreboot1 = GUICtrlCreateSlider(240, 150, 175, 20, $TBS_NOTICKS)

$Wreboot2 = GUICtrlSetLimit($Wreboot1, 30, 1)

GUICtrlSetData($Wreboot1,$inireboot1)

$Wreboot2 = GUICtrlRead($Wreboot1)

$Wreboot3 = GUICtrlCreatelabel("Reboot Timeout " & $Wreboot2 & ' Sec',270, 133)

$Wreboot4 = GUICtrlCreatecheckbox("Always reboot", 220, 170, 140, 20)

IF $inireboot2 = 1 then GUICtrlSetState($Wreboot3, $GUI_CHECKED)

IF $inireboot2 = 4 then GUICtrlSetState($Wreboot3, $GUI_UNCHECKED)

#endregion

#region ;progress type -------------------------------------------------------- working

$Wgroup5 = GUICtrlCreateGroup("Process type",10, 215, 195, 65)

$Wprocess1 = GUICtrlCreateradio("Type 1", 15, 230, 100)

GUICtrlSetTip(-1, " This will display one applications progress" & @CRLF &"with a progress bar")

$Wprocess2 = GUICtrlCreateradio("Type 2", 15, 250, 100)

GUICtrlSetTip(-1, " This will display all selected applications" & @CRLF &"with a list and progress bars")

$iniPR = iniread("config\config.ini", "Config", "PROGRESS_TYPE", "2")

if $iniPR == "1" then GUICtrlSetState($Wprocess1, $GUI_CHECKED)

if $iniPR == "2" then GUICtrlSetState($Wprocess2, $GUI_CHECKED)

#endregion

#region ;launched applications ------------------------------------------------ working

$Wgroup6 = GUICtrlCreateGroup("Launched Applications",215, 200, 225, 105)

$iniLA = iniread("config\config.ini", "Config", "WINDOWMODE", "1")

$WLA1 = GUICtrlCreateradio("Minimized", 220, 215, 80)

$WLA2 = GUICtrlCreateradio("Maximize", 220, 235, 80)

$WLA3 = GUICtrlCreateradio("Hidden", 220, 255, 80)

$WLA4 = GUICtrlCreateradio("Normal", 220, 275, 80)

$lable1 = GUICtrlCreatelabel("This does not affect" & @CRLF &"applications kept in the" & @CRLF &"Tools folder.",310, 235, 110, 50)

GUICtrlSetColor ( $lable1, 0xFF4242)

if $iniLA == "1" then GUICtrlSetState($WLA1, $GUI_CHECKED)

if $iniLA == "2" then GUICtrlSetState($WLA2, $GUI_CHECKED)

if $iniLA == "3" then GUICtrlSetState($WLA3, $GUI_CHECKED)

if $iniLA == "4" then GUICtrlSetState($WLA4, $GUI_CHECKED)

#endregion

#region ;admin warning--------------------------------------------------------- working

$Wgroup7 = GUICtrlCreateGroup("Administrator warning",10, 285, 195, 65)

$Wadw1 = GUICtrlCreateradio("Yes", 15, 300, 100)

$Wadw2 = GUICtrlCreateradio("No", 15, 320, 100)

$iniAW = iniread("config\config.ini", "Config", "ADMINWARNING", "1")

if $iniAW == "1" then GUICtrlSetState($Wadw1, $GUI_CHECKED)

if $iniAW == "2" then GUICtrlSetState($Wadw2, $GUI_CHECKED)

#endregion

GUISetState()

while 2

$msg1 = GUIGetMsg()

If $msg1 = $GUI_EVENT_CLOSE Then ExitLoop

select

case $msg1 = $Wbutton1 ;settings saved

_saveset()

case $msg1 = $Wbutton2 ;close

$qst = MsgBox(3, "Save before exit?", "Do you want to save your settings before closing the options menu?")

if $qst = 6 then

_saveset()

exit

endif

if $qst = 7 then Exit

if $qst = 2 then continueloop

;GUIDelete($Woption)

;GUIsetstate(@SW_show ,$main)

;exitloop

;exit

case $msg1 = $Walarm1 ;checkbox on alarm

$chk = GUICtrlRead ($Walarm1)

if $chk = $GUI_CHECKED then _alarmC1() ;checked

if $chk = $GUI_UNCHECKED then _alarmC2() ;not checked

case $msg1 = $Walarm3 ;button to select wav file

$selectF = FileOpenDialog("Select *wav file", @HomeDrive, "Wav files (*.wav)", 1 + 2)

GUICtrlSetdata($Walarm2, $selectF)

if GUICtrlRead($Walarm2) = 1 then GUICtrlSetdata($Walarm2, $inialarm2)

Case $msg1 = $Wlog1 ;Button to select file for log

$selectFDR = FileSelectFolder("Select path to folder where you want to keep log file", "", 1 + 2 + 4, @HomeDrive)

GUICtrlSetdata($Wlog2, $selectFDR)

Case $msg1 = $Wlog3 ;checkbox on log

if GUICtrlRead ($Wlog3) = $GUI_CHECKED then _logC1() ;checked

if GUICtrlRead ($Wlog3) = $GUI_UNCHECKED then _logC2() ;not checked

case Else

If $Wreboot2 <> GUICtrlRead($Wreboot1) Then

$Wreboot2 = GUICtrlRead($Wreboot1)

GUICtrlSetData($Wreboot3, 'Reboot Timeout ' & $Wreboot2 & ' Sec')

EndIf

case $msg1 = GUICtrlRead($Walarm2) = 1 then GUICtrlSetdata($Walarm2, $inialarm1)

endselect

wend

; alarm function - working

Func _alarmC1() ;Alarm checked

GUICtrlSetState($Walarm1, $GUI_CHECKED) ;checks box to enable selections of wav file

GUICtrlsetstate($Walarm3,$GUI_ENABLE) ;enables folder selector

GUICtrlSetTip($Walarm3, "Browse for file")

GUICtrlSetdata($Walarm2, $inialarm2) ;Sets data in filepath

EndFunc

Func _alarmC2() ;Alarm not checked

GUICtrlSetdata($Walarm2, @WindowsDir &"\media\chord.wav") ;sets data to default path

GUICtrlsetstate($Walarm3,$GUI_DISABLE) ;disables select folder button

EndFunc

#endregion

#region ; Log function - working

Func _logC1() ;Log checked

GUICtrlSetState($Wlog3, $GUI_CHECKED) ;checks box to enable selections of folder

GUICtrlsetstate($Wlog1,$GUI_ENABLE) ;enables folder selector

GUICtrlSetTip($Wlog1, "Browse for folder")

GUICtrlSetdata($Wlog2, $inilog2) ;Sets data in filepath

EndFunc

Func _logC2() ;Log not checked

GUICtrlSetdata($Wlog2, $inilog1) ;sets data to default path

GUICtrlsetstate($Wlog1,$GUI_DISABLE) ;disables select folder button

EndFunc

#endregion

Func _saveset() ;save settings

#region save logon

$save1 = GUICtrlRead($Wlogon1) ;ID_RunAs

$save2 = GUICtrlRead($Wlogon2) ;ID_AutoLogon

$save3 = GUICtrlRead($Wlogon3) ;Domain_RunAs

$save4 = GUICtrlRead($Wlogon4) ;Domain_AutoLogon

if $save1 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ID_RUNAS",0)

if $save1 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ID_RUNAS",1)

if $save2 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ID_AUTOLOGON",0)

if $save2 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ID_AUTOLOGON",1)

if $save3 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "DOMAIN_RUNAS",0)

if $save3 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "DOMAIN_RUNAS",1)

if $save4 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "DOMAIN_AUTOLOGON",0)

if $save4 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "DOMAIN_AUTOLOGON",1)

#endregion

#region save alarm

$save5 = GUICtrlRead($Walarm2) ;path to wav file )

$save6 = GUICtrlRead($Walarm1) ;checkbox that switches default wav and custom ;w

$save7 = GUICtrlRead($Walarm4) ;notify and exit

$save8 = GUICtrlRead($Walarm5) ;alarm and return

$save9 = GUICtrlRead($Walarm6) ;no default

MsgBox(0,"",$save5)

$test = IniWrite("config\config.ini", "Config", "ALARM_SOUND", $save5)

MsgBox(0,"",$test)

if $save6 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ALARM_CFG",0) ;w

if $save6 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_CFG",1) ;w

if $save7 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",1)

if $save8 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",2)

if $save9 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",3)

#endregion

#region save log

$save10 = GUICtrlRead($Wlog2) ;log folder path

$save11 = GUICtrlRead($Wlog3) ;checkbox that switches default log path and custom

$save12 = GUICtrlRead($Wlog4) ;Logging always switch

$save13 = GUICtrlRead($Wlog5) ;central logging

IniWrite("config\config.ini", "Config", "LOGPATH", $save10)

if $save11 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "LOGTYPE",4)

if $save11 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "LOGTYPE",1)

if $save12 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "LOG_ALWAYS",4)

if $save12 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "LOG_ALWAYS",1)

if $save13 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "CENTRAL_LOGGING",4)

if $save13 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "CENTRAL_LOGGING",1)

#endregion

#region save reboot

$save14 = GUICtrlRead($Wreboot1) ;reboot time input

$save15 = GUICtrlRead($Wreboot3) ;reboot always switch

IniWrite("config\config.ini", "Config", "REBOOTTIMER", $save14)

if $save15 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "REBOOTALWAYS",4)

if $save15 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "REBOOTALWAYS",1)

#endregion

#region save progress

$save16 = GUICtrlRead($Wprocess1);type 1

$save17 = GUICtrlRead($Wprocess1);type 2

if $save16 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "PROGRESS_TYPE",1)

if $save17 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "PROGRESS_TYPE",2)

#endregion

#region saved launched applications

$save18 = GUICtrlRead($WLA1) ;Minimized

$save19 = GUICtrlRead($WLA2) ;Maximize

$save20 = GUICtrlRead($WLA3) ;Hidden

$save21 = GUICtrlRead($WLA4) ;normal

if $save18 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",1)

if $save19 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",2)

if $save20 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",3)

if $save21 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",3)

#endregion

#region save Admin warning

$save22 = GUICtrlRead($Wadw1) ;warning

$save23 = GUICtrlRead($Wadw2) ;no warning

if $save22 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ADMINWARNING",1)

if $save23 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ADMINWARNING",2)

#endregion

msgbox(0,"Apply", "Settings saved")

EndFunc

Link to comment
Share on other sites

I got a head scratcher here. If I use the default path, I can write to the ini file. If I choose any other path, I get a error saying the file is read only. I put in a msgbox to test to see what was happening, and that is what I have been able to figure out.

The problem is with line 218.

here is the code:

CODE

#region

#include <GUIConstants.au3>

;GUISetHelp("config\help.hlp")

$Woption = GUICreate("Options", 450,360)

$Wbutton1 = GUICtrlCreateButton("Apply", 250, 315, 60, 25)

$Wbutton2 = GUICtrlCreateButton("Close", 340, 315, 60, 25)

#endregion

#region ;logon ---------------------------------------------------------------- working

$Wgroup1 = GUICtrlCreateGroup("Logon settings",10, 7, 195, 106)

$Wlgini1 = iniread("config\config.ini", "Config", "ID_RUNAS", "0")

$Wlogon1 = GUICtrlCreatecheckbox("Save logon ID for RunAs", 15, 25)

GUICtrlSetState($Wlogon1, $Wlgini1)

$Wlgini2 = iniread("config\config.ini", "Config", "ID_AUTOLOGON", "0")

$Wlogon2 = GUICtrlCreatecheckbox("Save logon ID for AutoLogon", 15, 45)

GUICtrlSetState($Wlogon2, $Wlgini2)

$Wlgini3 = iniread("config\config.ini", "Config", "DOMAIN_RUNAS", "0")

$Wlogon3 = GUICtrlCreatecheckbox("Save Domain name for RunAs", 15, 65)

GUICtrlSetState($Wlogon3, $Wlgini3)

$Wlgini4 = iniread("config\config.ini", "Config", "DOMAIN_AUTOLOGON", "0")

$Wlogon4 = GUICtrlCreatecheckbox("Save Domain name for AutoLogon", 15, 85)

GUICtrlSetState($Wlogon4, $Wlgini4)

#endregion ;this section is working

#region ;alarm ---------------------------------------------------------------- bug: displays message "1" if no file is selected.

$Wgroup2 = GUICtrlCreateGroup("Alarm settings",215, 7, 225, 106)

$inialarm1 = iniread("config\config.ini", "Config", "ALARM_CFG", "1") ;checkbox on or off

$inialarm2 = Iniread("config\config.ini", "Config", "Alarm_sound", @WindowsDir &"\media\chord.wav")

$inialarm3 = iniread("config\config.ini", "Config", "ALARM_TYPE", "3")

$Walarm1 = GUICtrlCreatecheckbox("", 220, 25, -1, 20) ;when checked, it will enable $Walarm1

$Walarm2 = GUICtrlCreateinput("", 243, 25, 155, 18, $ES_AUTOHSCROLL+$ES_READONLY) ;file path

$Walarm3 = GUICtrlCreatebutton(" . . . ", 405, 25, 25, 18 ) ;folder selector

if $inialarm1 == 1 then _alarmC1()

if $inialarm1 == 0 then _alarmC2()

GUICtrlSetTip($Walarm1, " If this box is checked, you"& @CRLF &"can select what sound you"& @CRLF &" wish to use for a alarm.")

;----------------------------

$Walarm4 = GUICtrlCreateradio("Notify and Exit as default", 220, 45, 155)

$Walarm5 = GUICtrlCreateradio("Alarm then Return as default", 220, 65, 155)

$Walarm6 = GUICtrlCreateradio("No default", 220, 85, 155)

if $inialarm3 == 1 then GUICtrlSetState($Walarm4, $GUI_CHECKED)

if $inialarm3 == 2 then GUICtrlSetState($Walarm5, $GUI_CHECKED)

if $inialarm3 == 3 then GUICtrlSetState($Walarm6, $GUI_CHECKED)

#endregion

#region ;log file ------------------------------------------------------------- working

$Wgroup3 = GUICtrlCreateGroup("Log file location",10, 120, 195, 90)

$inilog1 = Iniread("config\config.ini", "Config", "LOGPATH", EnvGet('SystemDrive'))

$inilog2 = iniread("config\config.ini", "Config", "LOGTYPE", 4)

$INILOG3 = iniread("config\config.ini", "Config", "LOG_ALWAYS", 4)

$INILOG4 = iniread("config\config.ini", "Config", "CENTRAL_LOGGING", 1)

$Wlog1 = GUICtrlCreatebutton(" . . . ", 175, 140, 25, 18) ;button for folder

$Wlog2 = GUICtrlCreateinput("", 35 ,140, 135, 18, $ES_AUTOHSCROLL+$ES_READONLY)

$Wlog3 = GUICtrlCreatecheckbox("", 15, 140, -1, 20) ;when checked, it will ungray the input box, and folder button

if $inilog2 == 1 then _logC1()

if $inilog2 == 4 then _logC2()

GUICtrlSetTip($Wlog3, "If this box is checked, you"& @CRLF &"can select the path you wish"& @CRLF &"to use for storing the log file.")

$Wlog4 = GUICtrlCreatecheckbox("Always log", 15, 160, 120, 20) ;turns on logging always

GUICtrlSetTip($Wlog4, "If checked, this will save a log of what was ran on"& @CRLF &"the PC by ScriptLoader, including any activation"& @CRLF &"keys entered.")

IF $INILOG3 = 1 then GUICtrlSetState($Wlog4, $GUI_CHECKED)

IF $INILOG3 = 4 then GUICtrlSetState($Wlog4, $GUI_UNCHECKED)

$Wlog5 = GUICtrlCreatecheckbox("Central Logging", 15, 180, 120, 20) ;turns on logging always

GUICtrlSetTip($Wlog5, "This will save copies of log files to /Config/C_log."& @CRLF &"If ALWAYS LOG is checked, it will simply make a"& @CRLF &"extra copy of the log file that is created on the"& @CRLF &"PC when ScriptLoader is ran.")

IF $INILOG4 = 1 then GUICtrlSetState($Wlog5, $GUI_CHECKED)

IF $INILOG4 = 4 then GUICtrlSetState($Wlog5, $GUI_UNCHECKED)

#endregion

#region ;Reboot --------------------------------------------------------------- working

$Wgroup4 = GUICtrlCreateGroup("Reboot",215, 120, 225,75)

$inireboot1 = iniread("config\config.ini", "Config", "REBOOTTIMER", "15")

$inireboot2 = iniread("config\config.ini", "Config", "REBOOTALWAYS", "4")

$Wreboot1 = GUICtrlCreateSlider(240, 150, 175, 20, $TBS_NOTICKS)

$Wreboot2 = GUICtrlSetLimit($Wreboot1, 30, 1)

GUICtrlSetData($Wreboot1,$inireboot1)

$Wreboot2 = GUICtrlRead($Wreboot1)

$Wreboot3 = GUICtrlCreatelabel("Reboot Timeout " & $Wreboot2 & ' Sec',270, 133)

$Wreboot4 = GUICtrlCreatecheckbox("Always reboot", 220, 170, 140, 20)

IF $inireboot2 = 1 then GUICtrlSetState($Wreboot3, $GUI_CHECKED)

IF $inireboot2 = 4 then GUICtrlSetState($Wreboot3, $GUI_UNCHECKED)

#endregion

#region ;progress type -------------------------------------------------------- working

$Wgroup5 = GUICtrlCreateGroup("Process type",10, 215, 195, 65)

$Wprocess1 = GUICtrlCreateradio("Type 1", 15, 230, 100)

GUICtrlSetTip(-1, " This will display one applications progress" & @CRLF &"with a progress bar")

$Wprocess2 = GUICtrlCreateradio("Type 2", 15, 250, 100)

GUICtrlSetTip(-1, " This will display all selected applications" & @CRLF &"with a list and progress bars")

$iniPR = iniread("config\config.ini", "Config", "PROGRESS_TYPE", "2")

if $iniPR == "1" then GUICtrlSetState($Wprocess1, $GUI_CHECKED)

if $iniPR == "2" then GUICtrlSetState($Wprocess2, $GUI_CHECKED)

#endregion

#region ;launched applications ------------------------------------------------ working

$Wgroup6 = GUICtrlCreateGroup("Launched Applications",215, 200, 225, 105)

$iniLA = iniread("config\config.ini", "Config", "WINDOWMODE", "1")

$WLA1 = GUICtrlCreateradio("Minimized", 220, 215, 80)

$WLA2 = GUICtrlCreateradio("Maximize", 220, 235, 80)

$WLA3 = GUICtrlCreateradio("Hidden", 220, 255, 80)

$WLA4 = GUICtrlCreateradio("Normal", 220, 275, 80)

$lable1 = GUICtrlCreatelabel("This does not affect" & @CRLF &"applications kept in the" & @CRLF &"Tools folder.",310, 235, 110, 50)

GUICtrlSetColor ( $lable1, 0xFF4242)

if $iniLA == "1" then GUICtrlSetState($WLA1, $GUI_CHECKED)

if $iniLA == "2" then GUICtrlSetState($WLA2, $GUI_CHECKED)

if $iniLA == "3" then GUICtrlSetState($WLA3, $GUI_CHECKED)

if $iniLA == "4" then GUICtrlSetState($WLA4, $GUI_CHECKED)

#endregion

#region ;admin warning--------------------------------------------------------- working

$Wgroup7 = GUICtrlCreateGroup("Administrator warning",10, 285, 195, 65)

$Wadw1 = GUICtrlCreateradio("Yes", 15, 300, 100)

$Wadw2 = GUICtrlCreateradio("No", 15, 320, 100)

$iniAW = iniread("config\config.ini", "Config", "ADMINWARNING", "1")

if $iniAW == "1" then GUICtrlSetState($Wadw1, $GUI_CHECKED)

if $iniAW == "2" then GUICtrlSetState($Wadw2, $GUI_CHECKED)

#endregion

GUISetState()

while 2

$msg1 = GUIGetMsg()

If $msg1 = $GUI_EVENT_CLOSE Then ExitLoop

select

case $msg1 = $Wbutton1 ;settings saved

_saveset()

case $msg1 = $Wbutton2 ;close

$qst = MsgBox(3, "Save before exit?", "Do you want to save your settings before closing the options menu?")

if $qst = 6 then

_saveset()

exit

endif

if $qst = 7 then Exit

if $qst = 2 then continueloop

;GUIDelete($Woption)

;GUIsetstate(@SW_show ,$main)

;exitloop

;exit

case $msg1 = $Walarm1 ;checkbox on alarm

$chk = GUICtrlRead ($Walarm1)

if $chk = $GUI_CHECKED then _alarmC1() ;checked

if $chk = $GUI_UNCHECKED then _alarmC2() ;not checked

case $msg1 = $Walarm3 ;button to select wav file

$selectF = FileOpenDialog("Select *wav file", @HomeDrive, "Wav files (*.wav)", 1 + 2)

GUICtrlSetdata($Walarm2, $selectF)

if GUICtrlRead($Walarm2) = 1 then GUICtrlSetdata($Walarm2, $inialarm2)

Case $msg1 = $Wlog1 ;Button to select file for log

$selectFDR = FileSelectFolder("Select path to folder where you want to keep log file", "", 1 + 2 + 4, @HomeDrive)

GUICtrlSetdata($Wlog2, $selectFDR)

Case $msg1 = $Wlog3 ;checkbox on log

if GUICtrlRead ($Wlog3) = $GUI_CHECKED then _logC1() ;checked

if GUICtrlRead ($Wlog3) = $GUI_UNCHECKED then _logC2() ;not checked

case Else

If $Wreboot2 <> GUICtrlRead($Wreboot1) Then

$Wreboot2 = GUICtrlRead($Wreboot1)

GUICtrlSetData($Wreboot3, 'Reboot Timeout ' & $Wreboot2 & ' Sec')

EndIf

case $msg1 = GUICtrlRead($Walarm2) = 1 then GUICtrlSetdata($Walarm2, $inialarm1)

endselect

wend

; alarm function - working

Func _alarmC1() ;Alarm checked

GUICtrlSetState($Walarm1, $GUI_CHECKED) ;checks box to enable selections of wav file

GUICtrlsetstate($Walarm3,$GUI_ENABLE) ;enables folder selector

GUICtrlSetTip($Walarm3, "Browse for file")

GUICtrlSetdata($Walarm2, $inialarm2) ;Sets data in filepath

EndFunc

Func _alarmC2() ;Alarm not checked

GUICtrlSetdata($Walarm2, @WindowsDir &"\media\chord.wav") ;sets data to default path

GUICtrlsetstate($Walarm3,$GUI_DISABLE) ;disables select folder button

EndFunc

#endregion

#region ; Log function - working

Func _logC1() ;Log checked

GUICtrlSetState($Wlog3, $GUI_CHECKED) ;checks box to enable selections of folder

GUICtrlsetstate($Wlog1,$GUI_ENABLE) ;enables folder selector

GUICtrlSetTip($Wlog1, "Browse for folder")

GUICtrlSetdata($Wlog2, $inilog2) ;Sets data in filepath

EndFunc

Func _logC2() ;Log not checked

GUICtrlSetdata($Wlog2, $inilog1) ;sets data to default path

GUICtrlsetstate($Wlog1,$GUI_DISABLE) ;disables select folder button

EndFunc

#endregion

Func _saveset() ;save settings

#region save logon

$save1 = GUICtrlRead($Wlogon1) ;ID_RunAs

$save2 = GUICtrlRead($Wlogon2) ;ID_AutoLogon

$save3 = GUICtrlRead($Wlogon3) ;Domain_RunAs

$save4 = GUICtrlRead($Wlogon4) ;Domain_AutoLogon

if $save1 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ID_RUNAS",0)

if $save1 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ID_RUNAS",1)

if $save2 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ID_AUTOLOGON",0)

if $save2 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ID_AUTOLOGON",1)

if $save3 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "DOMAIN_RUNAS",0)

if $save3 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "DOMAIN_RUNAS",1)

if $save4 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "DOMAIN_AUTOLOGON",0)

if $save4 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "DOMAIN_AUTOLOGON",1)

#endregion

#region save alarm

$save5 = GUICtrlRead($Walarm2) ;path to wav file )

$save6 = GUICtrlRead($Walarm1) ;checkbox that switches default wav and custom ;w

$save7 = GUICtrlRead($Walarm4) ;notify and exit

$save8 = GUICtrlRead($Walarm5) ;alarm and return

$save9 = GUICtrlRead($Walarm6) ;no default

MsgBox(0,"",$save5)

$test = IniWrite("config\config.ini", "Config", "ALARM_SOUND", $save5)

MsgBox(0,"",$test)

if $save6 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "ALARM_CFG",0) ;w

if $save6 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_CFG",1) ;w

if $save7 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",1)

if $save8 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",2)

if $save9 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ALARM_TYPE",3)

#endregion

#region save log

$save10 = GUICtrlRead($Wlog2) ;log folder path

$save11 = GUICtrlRead($Wlog3) ;checkbox that switches default log path and custom

$save12 = GUICtrlRead($Wlog4) ;Logging always switch

$save13 = GUICtrlRead($Wlog5) ;central logging

IniWrite("config\config.ini", "Config", "LOGPATH", $save10)

if $save11 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "LOGTYPE",4)

if $save11 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "LOGTYPE",1)

if $save12 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "LOG_ALWAYS",4)

if $save12 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "LOG_ALWAYS",1)

if $save13 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "CENTRAL_LOGGING",4)

if $save13 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "CENTRAL_LOGGING",1)

#endregion

#region save reboot

$save14 = GUICtrlRead($Wreboot1) ;reboot time input

$save15 = GUICtrlRead($Wreboot3) ;reboot always switch

IniWrite("config\config.ini", "Config", "REBOOTTIMER", $save14)

if $save15 = $GUI_UNCHECKED then IniWrite("config\config.ini","Config", "REBOOTALWAYS",4)

if $save15 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "REBOOTALWAYS",1)

#endregion

#region save progress

$save16 = GUICtrlRead($Wprocess1);type 1

$save17 = GUICtrlRead($Wprocess1);type 2

if $save16 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "PROGRESS_TYPE",1)

if $save17 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "PROGRESS_TYPE",2)

#endregion

#region saved launched applications

$save18 = GUICtrlRead($WLA1) ;Minimized

$save19 = GUICtrlRead($WLA2) ;Maximize

$save20 = GUICtrlRead($WLA3) ;Hidden

$save21 = GUICtrlRead($WLA4) ;normal

if $save18 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",1)

if $save19 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",2)

if $save20 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",3)

if $save21 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "WINDOWMODE",3)

#endregion

#region save Admin warning

$save22 = GUICtrlRead($Wadw1) ;warning

$save23 = GUICtrlRead($Wadw2) ;no warning

if $save22 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ADMINWARNING",1)

if $save23 = $GUI_CHECKED then IniWrite("config\config.ini","Config", "ADMINWARNING",2)

#endregion

msgbox(0,"Apply", "Settings saved")

EndFunc

the folder config must be existing!

if it does, everything works fine....

//Edit:

What about makin

if DirGetSize(@ScriptDir&"\config") = -1 Then
    DirCreate(@ScriptDir&"\config")
EndIf

to the first lines?

Edited by Analritter

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

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...