Jump to content

CTF Reminder


Recommended Posts

Below is the script I currently have for a CTF Reminder with a user interface. It's suppose to remind me every odd hour on the nose with the alert options that the user selected. I am having trouble with some problems with the User Interface, and need your assistance. ^^ As you can tell from the script I'm quite nooby at this, but learning along the way. Umm.. Problems I have right now are: Unable to save the settings to ini file on exit -You can see my feeble attempt, but to no avail-, Input box for beep count to be enabled when beep check box is checked. This is the only ones I can spot, but there's probably a ton more errors, call them like you see them please ^^ Thanks for your time and effort!

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

HotKeySet("{f8}", "ChangeSettings")

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Min_TimesUp = 0 ;The Minute to which User Requested to be alerted.
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput("Min", 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput("Min", 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput("0", 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    ;---Continuously Read the guiinputboxes to see if user made any changes.
    $T_Min = GUICtrlRead($T_MIN)
    $T_Start = GUICtrlRead($T_Start)
    $A_Number = GUICtrlRead($A_Number)
    $Min_TimesUp = $T_Start - $T_Min ;Start Time - Alert Prior Time = Minute to match to alert user.
    ;----------------------------------------------------------------------
    
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2) 
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
        
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in" & $T_Min & "minutes.")
        EndIf
        
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
        EndIf
    EndIf
    
    
    
    
    
    
    
;---------------------------GUI------------------------------

;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Number)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
;-------------------------------------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_Min)  
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_Start)
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $Play_Beep)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_Number)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", $SaveSettingState)
            EndIf
            Exit
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_Min)  
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_Start)
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $Play_Beep)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_Number)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", $SaveSettingState)
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

#cs Broken Items/Need to Impliment:

-Checkbox for beep to enable InputBox when checked.
-Save settings on exit.
-Load settings on startup if exist.
-IniWrite keeps producing 0s?

#ce
Link to comment
Share on other sites

  • Developers

You need to read the value of the control in stead of storing the ctrl handle. :)

eg:

IniWrite("CTFSettings.ini", "General Settings", "Time Notify", GuiCtrlRead($T_Min))

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

Below is the script I currently have for a CTF Reminder with a user interface. It's suppose to remind me every odd hour on the nose with the alert options that the user selected. I am having trouble with some problems with the User Interface, and need your assistance. ^^ As you can tell from the script I'm quite nooby at this, but learning along the way. Umm.. Problems I have right now are: Unable to save the settings to ini file on exit -You can see my feeble attempt, but to no avail-, Input box for beep count to be enabled when beep check box is checked. This is the only ones I can spot, but there's probably a ton more errors, call them like you see them please ^^ Thanks for your time and effort!

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

HotKeySet("{f8}", "ChangeSettings")

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Min_TimesUp = 0 ;The Minute to which User Requested to be alerted.
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput("Min", 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput("Min", 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput("0", 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    ;---Continuously Read the guiinputboxes to see if user made any changes.
    $T_Min = GUICtrlRead($T_MIN)
    $T_Start = GUICtrlRead($T_Start)
    $A_Number = GUICtrlRead($A_Number)
    $Min_TimesUp = $T_Start - $T_Min ;Start Time - Alert Prior Time = Minute to match to alert user.
    ;----------------------------------------------------------------------
    
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2) 
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
        
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in" & $T_Min & "minutes.")
        EndIf
        
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
        EndIf
    EndIf
    
    
    
    
    
    
    
;---------------------------GUI------------------------------

;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Number)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
;-------------------------------------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_Min)  
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_Start)
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $Play_Beep)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_Number)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", $SaveSettingState)
            EndIf
            Exit
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_Min)  
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_Start)
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $Play_Beep)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_Number)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", $SaveSettingState)
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

#cs Broken Items/Need to Impliment:

-Checkbox for beep to enable InputBox when checked.
-Save settings on exit.
-Load settings on startup if exist.
-IniWrite keeps producing 0s?

#ce
Here's one correctiopn you need to make, but there are a few the same.

$T_Min is the variable name you use for an input. Then you use the same variable name for the contents read from the input. You must not do that.

So Change

$T_Min = GuiCtrlRead($T_Min);this will only work once!
;and
IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_Min)

to

$T_MinText = GuiCtrlRead($T_Min)
;and
IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_minText)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thank you for your fast replies Jos and martin, much appreciated. :) Okay since both of you pretty much made the same suggestion, I changed it in my script, and went on and added all the final features I would like. And so far I would say it's very good, loads up settings, if non then reverts back to default. But one thing I'm still having trouble with is checkbox state, When I say close the program, it saves the settings, but when I reopen it again, all the old settings are reflected, except the checkboxes are reverted back to default. Ie, Beep = unchecked, and MsgBox = Checked even if I closed the program with opposite settings. Hopefully a trained eye can spot the errors of my script, the area I suspect is the problem is the "Loads Previous Settings on Startup" that I commented out. Thank you! :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

;---Loads Previous Settings on Startup----
$T_MinText = IniRead("CTFSettings.ini", "General Settings", "Time Notify", "5")
$T_StartText = IniRead("CTFSettings.ini", "General Settings", "CTF Start", "60")
$Min_TimesUp = IniRead("CTFSettings.ini", "General Settings", "Time at notify", "55")
$PlayBeepRead = IniRead("CTFSettings.ini", "General Settings", "Play Beep Checkbox", "0") ;alert
$PlayMsgBoxRead = IniRead("CTFSettings.ini", "General Settings", "Play MsgBox", "1") ;alert
$A_NumberText = IniRead("CTFSettings.ini", "General Settings", "Beep Count", "0")
$SaveSettingsText = IniRead("CTFSettings.ini", "General Settings", "Save Settings", "1") ;alert

if $SaveSettingsText = 1 then 
    $SaveSettings = $GUI_CHECKED
EndIf

If $PlayBeepRead = 1 Then
    $A_Beep = $GUI_CHECKED
ElseIf $PlayBeepRead = 0 Then
    $A_Beep = $GUI_UNCHECKED
EndIf

If $PlayMsgBoxRead = 1 Then
    $A_MsgBox = $GUI_CHECKED
ElseIf $PlayMsgBoxRead = 0 Then
    $A_MsgBox = $GUI_UNCHECKED
EndIf

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

HotKeySet("{f8}", "ChangeSettings")
AdlibEnable("BeepBox", 500)

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.
Global $PlayBeepRead = 0 ;Used to write Ini
Global $PlayMsgBoxRead = 0 ;Used to write Ini

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput($T_MinText, 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput($T_StartText, 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput($A_NumberText, 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Apply = GUICtrlCreateButton("Apply", 128, 88, 75, 25, $WS_GROUP)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2) 
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
        
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in " & $T_Min & " minutes.")
        EndIf
        
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
            $PlayBeepRead = 1
        EndIf
    EndIf
    
    
    
    
    
    
    
;---------------------------GUI------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
        Case $Apply
            ;Puts the Settings into effect.
            $T_MinText = GUICtrlRead($T_MIN)
            $T_StartText = GUICtrlRead($T_Start)
            $A_NumberText = GUICtrlRead($A_Number)
            $Min_TimesUp = $T_StartText - $T_MinText ;CTF start time - alert time = Time to match to alert the user.
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayMsgBoxRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

Func BeepBox()
;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Beep)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
EndFunc
;-------------------------------------------------------------
#cs Broken Items/Need to Impliment:

-Load settings on startup, checkboxes not matching.

#ce
Edited by lbrtdy
Link to comment
Share on other sites

Thank you for your fast replies Jos and martin, much appreciated. :) Okay since both of you pretty much made the same suggestion, I changed it in my script, and went on and added all the final features I would like. And so far I would say it's very good, loads up settings, if non then reverts back to default. But one thing I'm still having trouble with is checkbox state, When I say close the program, it saves the settings, but when I reopen it again, all the old settings are reflected, except the checkboxes are reverted back to default. Ie, Beep = unchecked, and MsgBox = Checked even if I closed the program with opposite settings. Hopefully a trained eye can spot the errors of my script, the area I suspect is the problem is the "Loads Previous Settings on Startup" that I commented out. Thank you! :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

;---Loads Previous Settings on Startup----
$T_MinText = IniRead("CTFSettings.ini", "General Settings", "Time Notify", "5")
$T_StartText = IniRead("CTFSettings.ini", "General Settings", "CTF Start", "60")
$Min_TimesUp = IniRead("CTFSettings.ini", "General Settings", "Time at notify", "55")
$PlayBeepRead = IniRead("CTFSettings.ini", "General Settings", "Play Beep Checkbox", "0") ;alert
$PlayMsgBoxRead = IniRead("CTFSettings.ini", "General Settings", "Play MsgBox", "1") ;alert
$A_NumberText = IniRead("CTFSettings.ini", "General Settings", "Beep Count", "0")
$SaveSettingsText = IniRead("CTFSettings.ini", "General Settings", "Save Settings", "1") ;alert

if $SaveSettingsText = 1 then 
    $SaveSettings = $GUI_CHECKED
EndIf

If $PlayBeepRead = 1 Then
    $A_Beep = $GUI_CHECKED
ElseIf $PlayBeepRead = 0 Then
    $A_Beep = $GUI_UNCHECKED
EndIf

If $PlayMsgBoxRead = 1 Then
    $A_MsgBox = $GUI_CHECKED
ElseIf $PlayMsgBoxRead = 0 Then
    $A_MsgBox = $GUI_UNCHECKED
EndIf

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

HotKeySet("{f8}", "ChangeSettings")
AdlibEnable("BeepBox", 500)

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.
Global $PlayBeepRead = 0 ;Used to write Ini
Global $PlayMsgBoxRead = 0 ;Used to write Ini

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput($T_MinText, 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput($T_StartText, 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput($A_NumberText, 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Apply = GUICtrlCreateButton("Apply", 128, 88, 75, 25, $WS_GROUP)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2) 
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
        
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in " & $T_Min & " minutes.")
        EndIf
        
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
            $PlayBeepRead = 1
        EndIf
    EndIf
    
    
    
    
    
    
    
;---------------------------GUI------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
        Case $Apply
            ;Puts the Settings into effect.
            $T_MinText = GUICtrlRead($T_MIN)
            $T_StartText = GUICtrlRead($T_Start)
            $A_NumberText = GUICtrlRead($A_Number)
            $Min_TimesUp = $T_StartText - $T_MinText ;CTF start time - alert time = Time to match to alert the user.
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayMsgBoxRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

Func BeepBox()
;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Beep)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
EndFunc
;-------------------------------------------------------------
#cs Broken Items/Need to Impliment:

-Load settings on startup, checkboxes not matching.

#ce
You aren't applying the state read from your ini to the checkbox

$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
;GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetState(-1, Number($SaveSettingsText));
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hmm I made the changes and it still doesn't seem like it worked. The thing is that those checkboxes when i'm saving the state to ini file I converted it to 1 = checked, 0 = unchecked, and I'm not sure if it's read correctly to be honest. Because you used GUICtrlSetState() to set the state of the check boxes, but you set the state to Number($SaveSettingsText) which sets the state = 0 or 1, but instead shouldn't the state be set to either $GUI_CHECKED or $GUI_UNCHECKED ? I need to convert the 1 or 0 from the ini file to $GUI_CHECKED or $GUI_UNCHECKED before applying the state?

This is what I have so far.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

;---Loads Previous Settings on Startup----
$T_MinText = IniRead("CTFSettings.ini", "General Settings", "Time Notify", "5")
$T_StartText = IniRead("CTFSettings.ini", "General Settings", "CTF Start", "60")
$Min_TimesUp = IniRead("CTFSettings.ini", "General Settings", "Time at notify", "55")
$PlayBeepRead = IniRead("CTFSettings.ini", "General Settings", "Play Beep Checkbox", "0") ;alert
$PlayMsgBoxRead = IniRead("CTFSettings.ini", "General Settings", "Play MsgBox", "1") ;alert
$A_NumberText = IniRead("CTFSettings.ini", "General Settings", "Beep Count", "0")
$SaveSettingsText = IniRead("CTFSettings.ini", "General Settings", "Save Settings", "1") ;alert
;-----------------------------------------

HotKeySet("{f8}", "ChangeSettings")
AdlibEnable("BeepBox", 500)

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.
Global $PlayBeepRead = 0 ;Used to write Ini
Global $PlayMsgBoxRead = 0 ;Used to write Ini

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput($T_MinText, 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput($T_StartText, 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput($A_NumberText, 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)
GUICtrlSetState(-1, Number($PlayBeepRead))
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
;GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetState(-1, Number($PlayMsgBoxRead))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
;GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetState(-1, Number($SaveSettingsText))
$Apply = GUICtrlCreateButton("Apply", 128, 88, 75, 25, $WS_GROUP)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2) 
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
        
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
            $PlayBeepRead = 1
        EndIf
        
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in " & $T_Min & " minutes.")
        EndIf
        

    EndIf
    
    
    
    
    
    
    
;---------------------------GUI------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
        Case $Apply
            ;Puts the Settings into effect.
            $T_MinText = GUICtrlRead($T_MIN)
            $T_StartText = GUICtrlRead($T_Start)
            $A_NumberText = GUICtrlRead($A_Number)
            $Min_TimesUp = $T_StartText - $T_MinText ;CTF start time - alert time = Time to match to alert the user.
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $Play_Beep = GUICtrlRead($A_Beep)
                if $Play_Beep = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayMsgBoxRead = 1
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

Func BeepBox()
;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Beep)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
EndFunc
;-------------------------------------------------------------
#cs Broken Items/Need to Impliment:

-Load settings on startup, checkboxes not matching.

#ce
Edited by lbrtdy
Link to comment
Share on other sites

Ah Okay, I get where you are going at, and yeah it works! Part of the problem was on my end also. Used so many variables that I wrote the ini file with one, but then read it using the wrong one. :/ Well problem is fixed now. Thank you for all your help :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

;---Loads Previous Settings on Startup----
$T_MinText = IniRead("CTFSettings.ini", "General Settings", "Time Notify", "5")
$T_StartText = IniRead("CTFSettings.ini", "General Settings", "CTF Start", "60")
$Min_TimesUp = IniRead("CTFSettings.ini", "General Settings", "Time at notify", "55")
$PlayBeepRead = IniRead("CTFSettings.ini", "General Settings", "Play Beep Checkbox", "0") ;alert
$PlayMsgBoxRead = IniRead("CTFSettings.ini", "General Settings", "Play MsgBox", "1") ;alert
$A_NumberText = IniRead("CTFSettings.ini", "General Settings", "Beep Count", "0")
$SaveSettingsText = IniRead("CTFSettings.ini", "General Settings", "Save Settings", "1")
;-----------------------------------------

HotKeySet("{f8}", "ChangeSettings")
AdlibEnable("BeepBox", 500)

Global $T_Min ;Minutes before CTF that the user wants to be notified.
Global $T_Start ;Time that CTF starts in minutes
Global $A_Number ;Number of beeps
Global $EvenHourOrOdd = 0 ;Hour odd or even?
Global $Count = 0 ;Just used to determine how many times beep is played.
Global $Start = 0 ;Used to trigger when to start monitoring.


#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("CTF Reminder", 366, 119, 451, 408)
$Group1 = GUICtrlCreateGroup("Time", 8, 0, 209, 81)
$T_Min = GUICtrlCreateInput($T_MinText, 152, 16, 57, 21)
GUICtrlSetLimit(-1, 2)
$T_Start = GUICtrlCreateInput($T_StartText, 152, 48, 57, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Alert X minutes prior to CTF:", 16, 16, 135, 17)
$Label2 = GUICtrlCreateLabel("Time that CTF starts (MIN):", 16, 48, 131, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Alert Options", 232, 0, 129, 81)
$A_Number = GUICtrlCreateInput($A_NumberText, 304, 16, 41, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
$A_Beep = GUICtrlCreateCheckbox("Beep", 240, 16, 57, 17)

;---load previous settings for beep checkbox---
if $PlayBeepRead = 1 Then
    GUICtrlSetState(-1, $GUI_CHECKED)
EndIf

;---load previous settings for msg checkbox---
$A_MsgBox = GUICtrlCreateCheckbox("Message Box Alert", 240, 48, 113, 17)
if $PlayMsgBoxRead = 1 Then
    GUICtrlSetState(-1, $GUI_CHECKED)
EndIf

GUICtrlCreateGroup("", -99, -99, 1, 1)
$SaveSettings = GUICtrlCreateCheckbox("Save Settings?", 16, 88, 97, 17)
if $SaveSettingsText = 1 Then
    GUICtrlSetState(-1, $GUI_CHECKED)
EndIf
$Apply = GUICtrlCreateButton("Apply", 128, 88, 75, 25, $WS_GROUP)
$Hide = GUICtrlCreateButton("Hide", 208, 88, 75, 25, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 288, 88, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
   
    $EvenHourOrOdd = _MathCheckDiv(@Hour, 2)
    if $EvenHourOrOdd = 2 and @MIN = $Min_TimesUp Then
         ;Alert the User!!!
        $Display_MsgBox = GUICtrlRead($A_MsgBox)
        $Play_Beep = GUICtrlRead($A_Beep)
       
        if $Play_Beep = $GUI_CHECKED Then
            While $Count < $A_Number ;Beep the number of times specified
                Beep(750,500)
                Sleep(500)
                $Count += 1
            WEnd
            $Count = 0
            $PlayBeepRead = 1
        EndIf
       
        if $Display_MsgBox = $GUI_CHECKED Then ;If the MsgBox option is checked, display checkbox.
            MsgBox(0,"Alert!","CTF will begin in " & $T_Min & " minutes.")
        EndIf
       

    EndIf
   
   
   
   
   
   
   
;---------------------------GUI------------------------------

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $PlayBeepRead = GUICtrlRead($A_Beep)
                if $PlayBeepRead = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                ElseIf $PlayBeepRead = $GUI_UNCHECKED Then
                    $PlayBeepRead = 0
                EndIf
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayMsgBoxRead = 1
                ElseIf $PlayMsgBoxRead = $GUI_UNCHECKED Then
                    $PlayMsgBoxRead = 0
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
        Case $Apply
            ;Puts the Settings into effect.
            $T_MinText = GUICtrlRead($T_MIN)
            $T_StartText = GUICtrlRead($T_Start)
            $A_NumberText = GUICtrlRead($A_Number)
            $Min_TimesUp = $T_StartText - $T_MinText ;CTF start time - alert time = Time to match to alert the user.
        Case $Hide
            ;Hides the UI.
            GUISetState(@SW_HIDE)
        Case $Exit
            $SaveSettingState = GUICtrlRead($SaveSettings)
            if $SaveSettingState = $GUI_CHECKED Then
                IniWrite("CTFSettings.ini", "General Settings", "Time Notify", $T_MinText)
                IniWrite("CTFSettings.ini", "General Settings", "CTF Start", $T_StartText)
                IniWrite("CTFSettings.ini", "General Settings", "Time at notify", $Min_TimesUp)
                $PlayBeepRead = GUICtrlRead($A_Beep)
                if $PlayBeepRead = $GUI_CHECKED Then
                    $PlayBeepRead = 1
                ElseIf $PlayBeepRead = $GUI_UNCHECKED Then
                    $PlayBeepRead = 0
                EndIf
                
                $PlayMsgBoxRead = GUICtrlRead($A_MsgBox)
                if $PlayMsgBoxRead = $GUI_CHECKED Then
                    $PlayMsgBoxRead = 1
                ElseIf $PlayMsgBoxRead = $GUI_UNCHECKED Then
                    $PlayMsgBoxRead = 0
                EndIf
                IniWrite("CTFSettings.ini", "General Settings", "Play Beep Checkbox", $PlayBeepRead)
                IniWrite("CTFSettings.ini", "General Settings", "Play MsgBox", $PlayMsgBoxRead)
                IniWrite("CTFSettings.ini", "General Settings", "Beep Count", $A_NumberText)
                IniWrite("CTFSettings.ini", "General Settings", "Save Settings", GUICtrlRead($SaveSettings))
            EndIf
            Exit
    EndSwitch
WEnd

Func ChangeSettings() ;When the User pushes f8, the UI pops up again.
    GUISetState(@SW_SHOW)
EndFunc

Func BeepBox()
;---Enables the box to specify however many beeps once the checkbox is checked.
    $DisableOrNot = GUICtrlRead($A_Beep)
    if $DisableOrNot = $GUI_CHECKED Then
        GUICtrlSetState($A_Number, $GUI_ENABLE)
    ElseIf $DisableOrNot = $GUI_UNCHECKED Then
        GUICtrlSetState($A_Number, $GUI_DISABLE)
    EndIf
EndFunc
;-------------------------------------------------------------
#cs Broken Items/Need to Impliment:

-Load settings on startup, checkboxes not matching.

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