; This is the part that reads the file to see what your settings are. Variables in the ini file are in all lowercase, variables here are CamelCase for more distinction
glovarini:=A_MyDocuments"\GloVar.ini" ; Location of the ini that the user modifies
glovarstart:="#SingleInstance force`n`n"
SetTimer,GloVar,2000 ; Check every 2 seconds
GloVar:
WinWaitNotActive,GloVar.ini ; So that we don't get any problems with the file on disk being out of date. I use VSCode with the "Save on lose focus" option on, YMMV
RegExMatch(Line,"^(?<Key>.*)=(?<Value>.*)",RE) ; Key = REKey, Value = REValue
If!(RESection) ; If the RegEx doesn't find antything, its empty
{
If!(REValue) ; If there is no value for the key, skip it (Continue the loop at the next line)
{
Continue
}
If InStr(StoredSection,"Serial Numbers") ; If the section is "Serial Numbers", make everything uppercase
{
StringUpper,REValue,REValue ; Makes it uppercase
WinWaitNotActive,GloVar.ini ; Just to make sure
{
ini_write(glovarini,REKey,REValue)
FileGetTime,gvMod,%glovarini%
}
}
If InStr(REKey,"case") ; If a key contains "case". Case numbers are all in the format "LETTERS-NUMBERS".
{
StringUpper,REValue,REValue ; Makes it uppercase
RegExMatch(REValue,"(?<=\().*(?=\))",REMatch) ; Match everything but the parenthesis. When the case numbers are shown they have parenthesis, and those are annoying.
If(REMatch) ; If there's anything there
{
WinWaitNotActive,GloVar.ini
{
ini_write(glovarini,REKey,REMatch) ; Writes the properly formatted case number to glovar.ini
FileGetTime,gvMod,%glovarini%
}
REValue:=REMatch
}Else{
WinWaitNotActive,GloVar.ini
{
ini_write(glovarini,REKey,REValue) ; Writes the properly formatted case number to glovar.ini
FileGetTime,gvMod,%glovarini%
}
}
}
writethis:=":*:$"REKey"::"REValue"`n" ; Save the hotstring to a variable
FileAppend,%writethis%,glovar.ahk ; Write the variable to glovar.ahk
}
If(RESection) ; If we have a section
{
StoredSection:=RESection
If InStr(RESection,"clear") ; Will clear the ini and save its and the documentation file's contents to a log
{
FileRead,doctemp,%docfile% ; Read documentation file, set in settings
FileRead,initemp,%glovarini% ; Read the ini
initemp:=RegExReplace(initemp,"(?<=\[)clear(?=\])","Info") ; Replace the "clear" section we set with Info
CurrTime:=GetDateTime("en") ; get the current date and time as "YYYY-MM-DD at HH:MM GMT"
writethis:="Case on ".CurrTime."`n`n`n".doctemp."`n`n".initemp ; Save the current time, what was in the doc file, and glovarini to a variable
FileAppend,%"`n`n"writethis"`n`n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",%A_MyDocuments%/D3KLog.txt ; Write a few new lines , the content, and a line underneath
FileAppend,,temptemp
FileCopy,glovarsource,%glovarini%,1 ; Copies and replaces any text in glovar.ini with the template
FileCopy,temptemp,%docfile%,1 ; These two this close together makes it look like they get cleared at the same time
FileDelete,temptemp
fileread,gvMod,%glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
FileDelete,glovar.ahk ; THE CLEAN SLATE
FileAppend,%glovarstart%,glovar.ahk
Sleep,500
FileGetTime,gvMod,%glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
If FileExist("glovar.ahk")
{
Runglovar.ahk
}
Return
}
}
}Until(file.AtEOF)
file.Close()
FileGetTime,gvMod,%glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
; So when editing Profiles, it won't let you paste in the email field. We don't like that. Make sure to let go of all keys immediatley after pressing this
#If,mjdpaste="1"
#v::
sleep,750
Send%clipboard%
sleep,500
send# ; to make sure the start menu isn't open for some reason