2023-02-13 16:20:22 -06:00
#SingleInstance force ; Only one instance at a time
SendMode , Input
FileEncoding , UTF - 8 ; Makes sure the special characters dont break stuff
SetWorkingDir , %A_MyDocuments% \D3K ; Make sure we can find the .ahks linked below
SetTitleMatchMode , 2
2019-12-17 10:57:15 -06:00
2023-02-13 16:20:22 -06:00
d3k_version := 3 ; The current version
2019-12-17 10:57:15 -06:00
2023-02-13 16:20:22 -06:00
GetDateTime ( lang )
2019-12-17 10:57:15 -06:00
{
2023-02-13 16:20:22 -06:00
FormatStr := " yyyy-MM-dd " ; The Date
FormatTime , DateStr , %A_NowUTC% , %FormatStr% ; format it to make it look like the Date we want
FormatStr := " H:mm'Z' " ; The time
FormatTime , TimeStr , %A_NowUTC% , %FormatStr% ; Format the string to be better
if ( lang = " en " )
{
Return DateStr " at " TimeStr
}
2019-12-17 10:57:15 -06:00
2023-02-13 16:20:22 -06:00
if ( lang = " de " )
{
Return DateStr " um " TimeStr
}
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
if ( lang = " ISO8601 " )
{
Return DateStr " T " TimeStr
}
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
if ( lang = " date " )
{
Return DateStr
}
}
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
GetInfo ( xID )
2019-12-17 10:57:15 -06:00
{
2023-02-13 16:20:22 -06:00
if ( xID )
2019-12-17 10:57:15 -06:00
{
2023-02-13 16:20:22 -06:00
File := FileOpen ( A_MyDocuments " \emails.csv " , " r " )
Loop
2020-02-03 02:54:31 -06:00
{
2023-02-13 16:20:22 -06:00
Line := File . ReadLine ( )
Array := StrSplit ( Line , " , " ) ; split the line at its separating commas to get separate "columns" AKA elements
if InStr ( Array [ 1 ] , xID ) ; if at the specified element (1) the specified content (dealers xID) has been found
2020-01-24 03:24:06 -06:00
{
2023-02-13 16:20:22 -06:00
Test := { xid : Array [ 1 ] , email : Array [ 2 ] , name : Array [ 3 ] , user : Array [ 4 ] , org : Array [ 5 ] } ; Return the array so we can do {variable}.email and so on
File . Close ( ) ; Close the file
Return Test ; Return the array with the deets that we found
2020-01-24 03:24:06 -06:00
}
2023-02-13 16:20:22 -06:00
} Until ( File . AtEOF )
File . Close ( )
Return false
}
if ! ( xID )
{
Return false
2020-01-23 08:46:40 -06:00
}
2019-12-17 10:57:15 -06:00
}
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
; INI Manipulation that supports UTF-8
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
ini_load ( location )
{
out := { }
File := FileOpen ( location , " r " )
cleaner := File . Read ( )
File . Close ( )
cleaner := RegExReplace ( cleaner , " `a m)^[\s\R]* " ) ; Remove empty lines
cleaner := RegExReplace ( cleaner , " m)[ \t]+$ " ) ; Get rid of extra space at the end of values (NEEDS FIXED)
File := FileOpen ( location , " w " )
File . Write ( cleaner )
File . Close ( )
File := FileOpen ( location , " r " )
Loop
{
Line := File . ReadLine ( )
RegExMatch ( Line , " (?<Section>(?<=\[).*(?=\]))|(?<Key>.*)=(?<Value>.*) " , r ) ; Key = rKey, Value = rValue, Section = rSection
If ( rSection )
{
rSection := Trim ( rSection , " `t`r`n " ) ; Remove pesky newlines and extra space
rSection := StrReplace ( rSection , " " , " § " ) ; AHK can't handle spaces in nested array names, so they're substituted with §
out[rSection]: = { }
c_Section := rSection
} Else
{
rKey := Trim ( rKey , " `t`r`n " )
rValue := Trim ( rValue , " `t`r`n " )
out [ c_Section , rKey ] := rValue
}
} Until ( File . AtEOF )
File . Close ( )
Return out
}
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
ini_write ( location , inKey , inValue ) ; Don't need to specify section because you can only have one hotstring anyway
{
Critical , On
file := FileOpen ( location , " r " )
temp := file . Read ( )
file . Close ( )
inKey := " (?<= " inKey " =)\S* " ; Regex to make sure we're matching only the value for the requested key
temp := RegExReplace ( temp , inKey , inValue )
; msgbox, % temp "`n`nRegex:`t" inKey "`nReplacing match with:`t" inValue
file := FileOpen ( location , " w " )
file . Write ( temp )
file . Close ( )
}
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
; Make sure the settings file exists, if not, create it
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
sett_ini := A_MyDocuments " \D3Ksettings.ini " ; Where the settings ini is
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
If ! FileExist ( sett_ini ) ; Check if the sett_ini doesn't exist
{
file := FileOpen ( sett_ini , " w " )
writethis := "
( L T r i m
[ USpec ]
Email = LastnameFirstname@JohnDeere . com
Name = Firstname
DocFile = Select File
[ Main ]
Mansol = 1
MJDPaste = 1
CaseFormatter = 1
CFmail = 0
[ Replacement ]
JDProductNames = 1
GloVar = 0
[ Language ]
German = 0
) "
file . Write ( writethis )
file . Close ( )
Run Settings . ahk ; Runs the GUI for changing the settings, accessible with Alt+Shift+\ (also easy way to restart this script)
}
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
; Read the sett_ini
2022-03-29 14:33:19 -05:00
;------------------------------------------------------------------------------
2023-02-13 16:20:22 -06:00
; This is the part that reads the file to see what your settings are. Variables in the sett_ini file are in all CamelCase, variables here are lowercase for more distinction
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
settings := { }
settings := ini_load ( sett_ini )
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
; User Specific things:
email := settings [ " USpec " , " Email " ]
name := settings [ " USpec " , " Name " ]
docfile := settings [ " USpec " , " DocFile " ]
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
; General Settings
mansol := settings [ " Main " , " Mansol " ]
supadmin := settings [ " Main " , " Supadmin " ]
mjdpaste := settings [ " Main " , " MJDPaste " ]
caseformatter := settings [ " Main " , " CaseFormatter " ]
cfmail := settings [ " Main " , " CFmail " ]
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
; Replacement
jdpn := settings [ " Replacement " , " JDProductNames " ]
glovar := settings [ " Replacement " , " GloVar " ]
2022-03-29 14:33:19 -05:00
2023-02-13 16:20:22 -06:00
; Language
ger := settings [ " Language " , " German " ]