minor updates

This commit is contained in:
David Daily 2023-02-13 16:20:22 -06:00
parent d537a9bf7b
commit e10c04c253
3 changed files with 153 additions and 491 deletions

604
func.ahk
View File

@ -1,20 +1,127 @@
#Include, func.ahk #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
d3k_version := 3 ; The current version
GetDateTime(lang)
{
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
}
if (lang = "de")
{
Return DateStr " um " TimeStr
}
if (lang = "ISO8601")
{
Return DateStr "T" TimeStr
}
if (lang = "date")
{
Return DateStr
}
}
GetInfo(xID)
{
if (xID)
{
File := FileOpen(A_MyDocuments "\emails.csv", "r")
Loop
{
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
{
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
}
} Until (File.AtEOF)
File.Close()
Return false
}
if !(xID)
{
Return false
}
}
;------------------------------------------------------------------------------
; INI Manipulation that supports UTF-8
;------------------------------------------------------------------------------
ini_load(location)
{
out := {}
File := FileOpen(location, "r")
cleaner := File.Read()
File.Close()
cleaner := RegExReplace(cleaner, "`am)^[\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
}
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()
}
Menu, Tray, Icon, shell32.dll, 283 ; Set the tray icon to a keyboard
Menu, Tray, Add, Mouse Mover, Mouse_Mover ; Add item to the tray to move the mouse
Menu, Tray, Add, %A_AhkVersion%, docs
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Make sure the settings file exists, if not, create it ; Make sure the settings file exists, if not, create it
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
sett_ini := A_MyDocuments "\D3Ksettings.ini" ; Where the settings ini is
If !FileExist(ini) ; Check if the ini doesn't exist If !FileExist(sett_ini) ; Check if the sett_ini doesn't exist
{ {
FileAppend, file := FileOpen(sett_ini, "w")
( writethis := "
; 0 is off, 1 is on ( LTrim
[USpec] [USpec]
RACF=LF01234
Email=LastnameFirstname@JohnDeere.com Email=LastnameFirstname@JohnDeere.com
Name=Firstname Name=Firstname
DocFile=Select File DocFile=Select File
@ -28,474 +135,35 @@ JDProductNames=1
GloVar=0 GloVar=0
[Language] [Language]
German=0 German=0
), %ini% )"
Run Settings.ahk ; Runs the GUI for changing the settings, also accessible with Alt+Shift+\ (also easy way to restart this script) 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)
} }
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Read the ini ; Read the sett_ini
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; 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 ; 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
settings := {}
settings := ini_load(sett_ini)
; User Specific things: ; User Specific things:
racf := ini_get(ini, "USpec", "RACF") email := settings["USpec", "Email"]
email := ini_get(ini, "USpec", "Email") name := settings["USpec", "Name"]
name := ini_get(ini, "USpec", "Name") docfile := settings["USpec", "DocFile"]
docfile := ini_get(ini, "USpec", "DocFile")
; General Settings ; General Settings
mansol := ini_get(ini, "Main", "Mansol") mansol := settings["Main", "Mansol"]
supadmin := ini_get(ini, "Main", "Supadmin") supadmin := settings["Main", "Supadmin"]
mjdpaste := ini_get(ini, "Main", "MJDPaste") mjdpaste := settings["Main", "MJDPaste"]
caseformatter := ini_get(ini, "Main", "CaseFormatter") caseformatter := settings["Main", "CaseFormatter"]
cfmail := settings["Main", "CFmail"]
; Replacement ; Replacement
jdpn := ini_get(ini, "Replacement", "JDProductNames") jdpn := settings["Replacement", "JDProductNames"]
glovar := ini_get(ini, "Replacement", "GloVar") glovar := settings["Replacement", "GloVar"]
; Language ; Language
ger := ini_get(ini, "Language", "German") ger := settings["Language", "German"]
;------------------------------------------------------------------------------
; Global Variables
;------------------------------------------------------------------------------
If (glovar = 1)
{
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
{
FileGetTime, gvModNew, %glovarini%
if !(gvModNew = gvMod) ; Those two lines mean the rest of this only executes if there were changes to the ini.
{
gvMod := gvModNew
FileDelete, glovar.ahk ; Start with a clean slate
FileAppend, %glovarstart%, glovar.ahk ; makes sure we only have one instance of the script running at a time
RESection := "" ; Make sure that its clear
file := FileOpen(glovarini, "r")
Loop ; Read one line at a time
{
Line := file.ReadLine()
RegExMatch(Line, "(?<=\[).*(?=\])", RESection) ; explained above
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")
{
Run glovar.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
If FileExist("glovar.ahk")
{
Run glovar.ahk
ToolTip, glovar updated, 50, 50
Sleep, 500
ToolTip
}
}
}
Return
}
;------------------------------------------------------------------------------
; Settings window
;------------------------------------------------------------------------------
!+\::Run Settings.ahk ; Alt+Shift+\
Mouse_Mover:
Run, msmv.ahk
Return
;------------------------------------------------------------------------------
; DTAC Solution Opener
;------------------------------------------------------------------------------
#If, mansol = "1" ; checks from the variable thats set from the .ini file
!+S::Run Mansol_Opener.ahk ; Alt+Shift+S
#If ; these are to make sure one "if" doesn't influence the next accidentially
;------------------------------------------------------------------------------
; Case Formatter
;------------------------------------------------------------------------------
#If, CaseFormatter = "1"
Pause::Run Case_Formatter.ahk ; The Pause|Break key
#If
;-------------------------------------------------------------------------------
; Special Characters
;-------------------------------------------------------------------------------
#If, ger = "1"
; scharfes s / Eszett / ß
!s::Send {U+00DF} ;Alt+S
; ä
!a::Send {U+00E4} ;Alt+a
; ö
!o::Send {U+00F6} ;Alt+o
; ü
!u::Send {U+00FC} ;Alt+u
; Ä
+!A::Send {U+00C4} ;Alt+A
; Ö
+!O::Send {U+00D6} ;Alt+O
; Ü
+!U::Send {U+00DC} ;Alt+U
#If
;-------------------------------------------------------------------------------
; Capitalise dates
;-------------------------------------------------------------------------------
::monday::Monday
::tuesday::Tuesday
::wednesday::Wednesday
::thursday::Thursday
::friday::Friday
::saturday::Saturday
::sunday::Sunday
::january::January
::february::February
; ::march::March ; Commented out because it matches the common word "march".
::april::April
; ::may::May ; Commented out because it matches the common word "may".
::june::June
::july::July
::august::August
::september::September
::october::October
::november::November
::december::December
; German
#If, ger = "1"
::montag::Montag
::dienstag::Dienstag
::mittwoch::Mittwoch
::donnerstag::Donnerstag
::freitag:: Freitag
::samstag::Samstag
::sonntag::Sonntag
::januar::Januar
::februar::Februar
::märz::März
::mai::Mai
::juni::Juni
::juli::Juli
::oktober::Oktober
::dezebmer::Dezember
#If
;------------------------------------------------------------------------------
; Copypastas
;------------------------------------------------------------------------------
;STWA Applied
:*:]cms::
Send STWA applied{Enter 2}Status: Providing information{Enter 2}Comments:{Space}{Enter 2}Thank you,{Enter}%name%{Enter 2}Tier 2 internal steps:{Space}{Enter 2}SQL:{Enter}
Return
;------------------------------------------------------------------------------
; Email
;------------------------------------------------------------------------------
; Regular
:*:]email::
Send Hello,{Enter 2}{Space 3}
Return
; German
#If, ger = "1"
; Regular
:*:[email::
Send Hallo,{Enter 2}{Space 3}
Return
#If
;------------------------------------------------------------------------------
; Profile email paste
;------------------------------------------------------------------------------
; 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
return
#If
;------------------------------------------------------------------------------
; Common Terms autocorrect and replacement
;------------------------------------------------------------------------------
#If, not(racf = "LF01234") ; So that it doesn't put the fake RACF from the default ini file
:*:]me::
Send, %racf%
return
:*:[me::
Send, %racf%
return
#If
#If, not(email = "LastnameFirstname@JohnDeere.com") ; Same as above
:*:@me::
Send, %email%
Return
#If
; JD Names
#If, jdpn = "1"
:*:[xx::XXXXXXXXXXXXX ; I'm not gonna try and find the right amount of X's to appease the CCMS demons
:*:]xx::XXXXXXXXXXXXX
; English
:*:]at::AutoTrac
:*:]sf::StarFire
:*:]jdld::JDLink Dashboard
:*:]jdlc::JDLink Connectivity
:*:]jdls::JDLink Subscription
:*:]jdll::JDLink
:*:]jdp::JDParts
:*:]mjd::MyJohnDeere
:*:]opsc::Operations Center
:*:]seccon::Section Control
:*:]gs::GreenStar
:*:]cc::CommandCenter
:*:]fc::Field Connect
:*:]rs::RowSense
:*:]sub::subscription
:*:]ss::Stellar Support
:*:]tman::Technical Manual
:*:]oman::Operator's Manual
:*:]hl3::HarvestLab 3000
:*:]hlo::Original HarvestLab
:*:]bin::Virtual Inventory
:*:]warrep::Warranty Reports
:*:]tcsm::Territory Customer Support Manager
:*:]macrep::Machine Reports
:*:]jdsm::John Deere Software Manager
:*:]jddm::John Deere Data Manager
:*:]serva::Service Advisor
:*:]muc::Master Unlock Code
:*:]asmn::Asset Manager
:*:]bsm::Base Station Manager
::rowsense::RowSense
:*:comar::COMAR
::mrtk::mRTK
::rda::RDA
::rtk::RTK
::autotrac::AutoTrac
:*:ccms::CCMS
:*:dtac::DTAC
::tcsm::TCSM
::itec::iTEC Pro
::ssu::SSU
::atu::ATU
:*:mtg::MTG
::wdt::WDT
::itc::iTC
:*:vin::Machine PIN ; Not actually vehicles, so they don't have VINs
::gs2::GS2
::gs3::GS3
::sf1::SF1
::sf2::SF2
::sf3::SF3
::sf4::SF4
::xid::xID
::pmcalc::PMCalc
::vat::VAT
:*:racf::RACF
::igrade::iGrade
:*:JDCP::JDCP
:*:ISOBUS::ISOBUS
; German
#If, ger = "1"
:*:[at::AutoTrac
:*:[sf::StarFire
:*:[jdlw::JDLink Web
:*:[jdld::JDLink Dashboard
:*:[jdl2::JDLink Dashboard 2.0
:*:[jdlc::JDLink Connectivity
:*:[jdls::JDLink Abonnement
:*:[jdll::JDLink
:*:[jdp::JDParts
:*:[mjd::MyJohnDeere
:*:[opsc::Einsatzzentrale
:*:[seccon::Teilbreitensteuerung
:*:[gs::GreenStar
:*:[cc::CommandCenter
:*:[fc::Field Connect
:*:[rs::RowSense
:*:[sub::Abonnement
:*:[ss::Stellar Support
:*:[tman::Technische Betriebsanleitung
:*:[oman::Betriebsanleitung
:*:[hl3::HarvestLab 3000
:*:[hlo::Originales HarvestLab
:*:[bin::Virtuellen Bestand
:*:[warrep::Warranty Reports
:*:[tp::TouchPoint
:*:[tcsm::Technischer Bezirksleiter
:*:[macrep::Machine Reports
:*:[jdsm::John Deere Software Manager
:*:[jddm::John Deere Data Manager
:*:[serva::Service Advisor
:*:[muc::Master Unlock Code
:*:[asmn::Asset Manager
:*:[bsm::Base Station Manager
#If
;------------------------------------------------------------------------------
; QoL Improvements
;------------------------------------------------------------------------------
#j:: ; Open the downloads folder on Win+J
Run, C:\Users\%racf%\Downloads
Return
#w:: ; Open My Documents folder on Win+W
Run, C:\Users\%racf%\Documents
Return
:*:[now:: ; Send the current time/date in ISO8601 format
:*:]now::
d_t := GetDateTime("ISO8601")
SendInput, %d_t%
Return
:*:[today:: ; Send the current date in ISO8601 format
:*:]today::
d_t := GetDateTime("date")
SendInput, %d_t%
Return
:*:[deg::{ASC 248}
:*:]deg::{ASC 248}
:*:[eq::{ASC 247}
:*:]eq::{ASC 247}
:*:[shrug::¯\_()_/¯
:*:]shrug::¯\_()_/¯
asciiart(art)
{
For index, value in art
{
SendInput, %value%{ShiftDown}{Enter}{ShiftUp}
}
Return
}
:*:]yee::
art := ["░░░░░░░░░░░░░▄███▄▄▄░░░░░░░","░░░░░░░░░▄▄▄██▀▀▀▀███▄░░░░░","░░░░░░░▄▀▀░░░░░░░░░░░▀█░░░░","░░░░▄▄▀░░░░░░░░░░░░░░░▀█░░░","░░░█░░░░░▀▄░░▄▀░░░░░░░░█░░░","░░░▐██▄░░▀▄▀▀▄▀░░▄██▀░▐▌░░░","░░░█▀█░▀░░░▀▀░░░▀░█▀░░▐▌░░░","░░░█░░▀▐░░░░░░░░▌▀░░░░░█░░░","░░░█░░░░░░░░░░░░░░░░░░░█░░░","░░░░█░░▀▄░░░░▄▀░░░░░░░░█░░░","░░░░█░░░░░░░░░░░▄▄░░░░█░░░░","░░░░░█▀██▀▀▀▀██▀░░░░░░█░░░░","░░░░░█░░▀████▀░░░░░░░█░░░░░","░░░░░░█░░░░░░░░░░░░▄█░░░░░░","░░░░░░░██░░░░░█▄▄▀▀░█░░░░░░","░░░░░░░░▀▀█▀▀▀▀░░░░░░█░░░░░", "yee ░░░░░█░░░░░░░░░░░░█░░░░"]
asciiart(art)
Return
:*:]glass::
art := ["▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄", "█░░░░░░░░▀█▄▀▄▀██████░▀█▄▀▄▀██████░", "░░░░░░░░░░░▀█▄█▄███▀░░░▀██▄█▄███▀░"]
asciiart(art)
Return
docs:
run https://www.autohotkey.com/docs/AutoHotkey.htm
Return

View File

@ -1,11 +1,5 @@
[Serial Numbers] [Serial Numbers]
1= 1=
ch= cm=
2=
MTG=
VIN=
[Operations Center]
usr=
org=
[Info] [Info]
ccms= case=

View File

@ -1,7 +1,7 @@
#SingleInstance, force #SingleInstance, force
CoordMode, Mouse, Screen CoordMode, Mouse, Screen
waittime := 180000 waittime := 160000
Switch A_Args[1] Switch A_Args[1]
{ {