98 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			AutoHotkey
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			AutoHotkey
		
	
	
	
	
	
#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
 | 
						|
 | 
						|
d3k_version = 2.6		; The current version
 | 
						|
 | 
						|
ini = %A_MyDocuments%\D3Ksettings.ini	; Where the settings ini is
 | 
						|
 | 
						|
GetDateTime(lang)
 | 
						|
{
 | 
						|
	UTCTimestamp := A_NowUTC    ; Grab the current time and date
 | 
						|
	UTCFormatStr := "yyyy-MM-dd"    ; This is what we want it to look like
 | 
						|
	FormatTime, DateStr, %UTCTimestamp%, %UTCFormatStr% ; format it to make it look like the Date we want
 | 
						|
	UTCFormatStr := "H:mm' GMT'"   ; The time
 | 
						|
	FormatTime, TimeStr, %UTCTimestamp%, %UTCFormatStr% ; Format the string to be better
 | 
						|
	if (lang = "en")
 | 
						|
	{
 | 
						|
		Return DateStr " at " TimeStr
 | 
						|
	}
 | 
						|
 | 
						|
	if (lang = "de")
 | 
						|
	{
 | 
						|
		Return DateStr " um " TimeStr
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
GetInfo(xID)	; Accept what is passed here as the variable "xID" in the script
 | 
						|
{
 | 
						|
	if (xID)
 | 
						|
	{
 | 
						|
		Loop, Read, %A_MyDocuments%\Work_Docs\emails.csv    ; read every line of "emails.csv"
 | 
						|
			{
 | 
						|
				Array := StrSplit(A_LoopReadLine,",")	; 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,
 | 
						|
				Break                                   ; stop searching
 | 
						|
			}
 | 
						|
		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
 | 
						|
		Return Test
 | 
						|
	}
 | 
						|
	if !(xID)
 | 
						|
	{
 | 
						|
		Return
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
;------------------------------------------------------------------------------
 | 
						|
; INI Manipulation that supports UTF-8
 | 
						|
;------------------------------------------------------------------------------
 | 
						|
 | 
						|
ini_load(location)
 | 
						|
{
 | 
						|
	out := {}
 | 
						|
	Loop, Read, %location%
 | 
						|
	{
 | 
						|
		RegExMatch(A_LoopReadLine, "(?<=\[).*(?=\])", _RESection)	; Matches section name
 | 
						|
		RegExMatch(A_LoopReadLine, "(?<Key>.*)=(?<Value>.*)", _)	; Key = _Key, Value = _Value
 | 
						|
 | 
						|
		If (_RESection)
 | 
						|
		{
 | 
						|
			_RESection := StrReplace(_RESection, " ", "_")
 | 
						|
			out[_RESection]:={}
 | 
						|
            currentSection := _RESection
 | 
						|
		} Else {
 | 
						|
			If (_Value)
 | 
						|
			{
 | 
						|
				_Key := StrReplace(_Key, " ", "_")
 | 
						|
				out[currentSection][_Key] := _Value
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	Return out
 | 
						|
}
 | 
						|
 | 
						|
ini_getValue(location, inSec, inKey)
 | 
						|
{
 | 
						|
	ini_loaded := {}
 | 
						|
	ini_loaded := ini_load(location)
 | 
						|
 | 
						|
	inSec := StrReplace(inSec, " ", "_")
 | 
						|
	inKey := StrReplace(inKey, " ", "_")
 | 
						|
 | 
						|
	Return ini_loaded[inSec][inKey]
 | 
						|
}
 | 
						|
 | 
						|
ini_writeValue(location, inKey, inValue)
 | 
						|
{
 | 
						|
	FileRead, tempini, %location%
 | 
						|
	needle := inKey . "=.*"
 | 
						|
	replacement := inKey . "=" . inValue
 | 
						|
	tempini := RegExReplace(tempini, needle, replacement,, 1)
 | 
						|
	tempini := RegExReplace(tempini, "\R+\R", "`r`n")
 | 
						|
	WinWaitNotActive, GloVar.ini
 | 
						|
	FileAppend, %tempini%, tempini		; Append the fixed ini to a new file
 | 
						|
	FileCopy, tempini, %location%, 1	; Copy the file over, overwriting existing contents
 | 
						|
	FileDelete, tempini					; Delete the fixed temporary ini
 | 
						|
} |