d3k/D3K.ahk
David Daily 3f751fcbf1 Trying to fix bad behaviour
it keeps the previous data from the xID lookup in the created glovar.ahk instead of the new information.
2020-01-08 09:07:42 -06:00

612 lines
22 KiB
AutoHotkey

#Include, func.ahk
Menu, Tray, Icon, shell32.dll, 283 ; Set the tray icon to a keyboard
SetWorkingDir, %A_MyDocuments%\D3K ; Make sure we can find the .ahks linked below
ini = %A_MyDocuments%\D3Ksettings.ini ; Where the settings ini is
;------------------------------------------------------------------------------
; Make sure the settings file exists, if not, create it
;------------------------------------------------------------------------------
If !FileExist(ini) ; Check if the ini doesn't exist
{
FileAppend,
(
; 0 is off, 1 is on
[USpec]
RACF=LF01234
Email=LastnameFirstname@JohnDeere.com
DocFile=Select File
[Main]
Mansol=1
Supadmin=1
MJDPaste=1
CaseFormatter=1
[Replacement]
Symbols=1
JDProductNames=1
GloVar=0
[Language]
German=0
[Info]
Version=0
), %ini%
Run Settings.ahk ; Runs the GUI for changing the settings, also accessible with Alt+Shift+\ (also easy way to restart this script)
}
;------------------------------------------------------------------------------
; Read the 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
; User Specific things:
racf := ini_getValue(ini, "USpec", "RACF")
email := ini_getValue(ini, "USpec", "Email")
docfile := ini_getValue(ini, "USpec", "DocFile")
; General Settings
mansol := ini_getValue(ini, "Main", "Mansol")
supadmin := ini_getValue(ini, "Main", "Supadmin")
mjdpaste := ini_getValue(ini, "Main", "MJDPaste")
caseformatter := ini_getValue(ini, "Main", "CaseFormatter")
; Replacement
symb := ini_getValue(ini, "Replacement", "Symbols")
jdpn := ini_getValue(ini, "Replacement", "JDProductNames")
glovar := ini_getValue(ini, "Replacement", "GloVar")
; Language
ger := ini_getValue(ini, "Language", "German")
;------------------------------------------------------------------------------
; Global Variables
;------------------------------------------------------------------------------
If (glovar = 1)
{
glovarini = %A_MyDocuments%\GloVar.ini ; Location of the ini that the user modifies
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, #SingleInstance force`n`n, glovar.ahk ; makes sure we only have one instance of the script running at a time
RESection := "" ; Make sure that its clear
Loop, Read, %glovarini% ; Read one line at a time
{
RegExMatch(A_LoopReadLine, "(?<=\[).*(?=\])", RESection) ; explained above
RegExMatch(A_LoopReadLine, "^(?<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_writeValue(glovarini, REKey, REValue)
FileGetTime, gvMod, %glovarini%
}
}
If InStr(StoredSection, "Operations Center") ; If the section is "Operations Center" and the Key "un", make it uppercase
{
If InStr(REKey, "usr")
{
StringUpper, REValue, REValue ; Makes it uppercase
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
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_writeValue(glovarini, REKey, REMatch) ; Writes the properly formatted case number to glovar.ini
FileGetTime, gvMod, %glovarini%
}
REValue := REMatch
} Else {
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
FileGetTime, gvMod, %glovarini%
}
}
}
If InStr(REKey, "xid") ; If an xID is entered. Unique identifier for people
{
dealinfo := GetInfo(REValue) ; Gets information, see function for details
StringUpper, REValue, REValue ; Makes xID uppercase
WinWaitNotActive, GloVar.ini
{
ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase
ini_writeValue(glovarini, "dem", dealinfo.email) ; Writes email address (incredibly useful)
ini_writeValue(glovarini, "dnm", dealinfo.name) ; Writes Name (useful for when referring to that person)
ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful)
}
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
}
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" . doctemp . "`n`n" . initemp ; Save the current time, what was in the doc file, and glovarini to a variable
FileAppend, % "`n`n`n`n" writethis "`n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", %A_MyDocuments%/D3KLog.txt ; Write a few new lines , the content, and a line underneath
FileCopy, glovarsource, %glovarini%, 1 ; Copies and replaces any text in glovar.ini with the template
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, #SingleInstance force`n`n, 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
}
Break
}
}
}
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
}
;------------------------------------------------------------------------------
; Settings window
;------------------------------------------------------------------------------
!+\::Run Settings.ahk ; Alt+Shift+\
;------------------------------------------------------------------------------
; 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
; These things below are for using in a pinch, or when there is no dealer.
SetTitleMatchMode, 2
#If (WinActive = Temp.txt) && (CaseFormatter = "1")
:*:\case::
CurrTime := GetDateTime("en")
Send Call received on %CurrTime% {Enter}Name: {Enter}Username: {Enter}
Return
#If
;German
#If (CaseFormatter = "1") && (ger = "1")
:*:|case::
CurrTime := GetDateTime("de")
Send Anruf wurde am %CurrTime% entgegengenommen{Enter}Name: {Enter}Benutzername: {Enter}
Return
#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
;------------------------------------------------------------------------------
; Recommending case
:*:]rec::
Send Recommending Case, please contact us if there are any further questions.
Return
; Escalatimg Case
:*:]esc1::
Send This case was unable to be resolved and has been transferred to another team. Our Tier 2 team is investigating the issue to find a short term resolution. We will update you as soon as we have a recommendation.
Return
:*:]esc2::
Send A short term resolution still has not been identified. We are requesting an immediate update on this case from our Tier 2 team. We will contact you as soon as we have a status update.
Return
; Requesting info
:*:]req1::
Send A request has been made for additional information in this case. Please provide the information as soon as possible so that the case can be resolved.
Return
:*:]req2::
Send A follow-up request has been made for the additional information.
Return
:*:]req3::
Send The additional information required has not yet been received. This case will now be sent back to you. Please reopen the case, or contact the Global Support Center again via phone or email with the additional information and reference this case number so that it can be reopened and investigated further.
Return
; Defect / NCCA
:*:]ncca::
Send We will be recommending this case back to you for the time being. This issue is still being investigated and worked on via an internal product corrective action ticket. We will continue to monitor the progress of that ticket and contact you when we have a solution or a short term recommendation. The case text will be updated at that time for documentation purposes.{Enter}You may choose to close this case yourself, return it to us, or keep it open until we provide you with a corrective action recommendation. If you have questions on the status of this issue, please re-open the case or contact the Global Support Center using the contact information found in DTAC solution 82793. We will provide you with any information we are able to gather from the product team.
Return
; DTAC
:*:]dtac::
Send The ISG Global Support Center has determined that this case is hardware related; therefore this case is being transferred from the GSC to the ISG DTAC group. A DTAC technician will now work this case via the CCMS system and provide a recommendation in the case text if more information is needed or if a solution has been found. Please continue to update or check on the progress of this case by using the CCMS system case text section moving forward.
Return
; German
#If, ger = "1"
; Recommending Case
:*:[rec::
Send Fall an H{U+00E4}ndler gewiesen, bitte melden Sie sich wenn sie weitere fragen haben.
Return
; Escalating Case
:*:[esc1::
Send Der Fall konnte vom GSC nicht gelöst werden und wurde an die nächste Supportebene weitergeleitet. Das Support Team wird das Problem weiter untersuchen und versuchen eine kurzfristige Lösung bereit zu stellen. Sobald wir eine Empfehlung erhalten, werden wir Sie darüber informieren.
Return
:*:[esc2::
Send Bisher steht uns keine kurzfristige Lösung zur Verfügung. Wir fordern umgehend ein Status-Update bezüglich des Falls von unserem Support Team an.{Shift down}{Enter}{Shift up}Wir werden Sie erneut kontaktieren, sobald wir über den aktuellsten Stand des Falls informiert sind.
Return
; Requesting info
:*:[req1::
Send Wir haben zusätzliche Informationen von Ihnen bezüglich des Falls angefordert. Bitte stellen Sie uns die Informationen so bald wie möglich zur Verfügung, damit der Fall gelöst werden kann.
Return
:*:[req2::
Send Wir fordern die zusätzlichen Informationen von Ihnen erneut an.
Return
:*:[req3::
Send Wir haben die benötigten zusätzlichen Informationen von Ihnen noch nicht erhalten. Dieser Fall wird jetzt zu Ihnen zurückgeschickt. Bitte setzen Sie sich mit dem GSC telefonisch oder per Email mit den zusätzlichen Informationen nochmal in Verbindung und referenzieren Sie die Fallnummer, damit der Fall erneut geöffnet und weiter untersucht werden kann.
Return
; Defect / NCCA
:*:[ncca::
Send Wir werden diesen Fall vorübergehend an Sie zurückweisen. Dieses Problem wird noch über ein innenseitiges Produkt Korrektur Ticket bearbeitet. Wir werden weiterhin den Fortschritt dieses Tickets verfolgen und mit Ihnen Kontakt aufnehmen, wenn wir eine Lösung oder eine kurzfristige Empfehlung haben.{Enter}Sie können diesen Fall selbst schließen, an uns zurückzugeben oder offen halten, bis wir Ihnen eine Korrekturmaßnahme empfehlen. Wenn Sie Fragen zum Fall Status haben wenden Sie sich an das Global Support Center, indem Sie die Kontaktinformationen in der DTAC-Lösung 82793 abrufen. Wir werden Ihnen alle Informationen, die wir von dem Produktteam bekommen haben, zu Verfügung stellen.
Return
; DTAC
:*:[dtac::
Send Das ISG Global Support Center hat festgestellt, dass dieser Fall hardwarebezogen ist; Daher wird dieser Fall vom GSC an die ISG DTAC Gruppe übertragen. Ein DTAC-Techniker wird nun diesen Fall über das DTAC-System bearbeiten und eine Empfehlung im Fall Text geben, wenn weitere Informationen benötigt werden oder wenn eine Lösung gefunden wurde. Dementsprechend bitten wir Sie, den Fortschritt des Falls mithilfe des Falltextes zu überprüfen und falls nötig mit fehlenden Informationen zu ergänzen.
Return
#If
;------------------------------------------------------------------------------
; Email
;------------------------------------------------------------------------------
; Regular
:*:]email::
Send Hello,{Enter 2} {Shift down}{Enter}{Shift up}Please contact us if you have any questions.{Up}{End}
Return
; DTAC Problem
:*:]97010::
Send Hello,{Enter 2} As this is a hardware/compatibility related inquiry, we here at the GSC cannot assist you properly. Please contact DTAC and they will be able to assist you further.
Return
; 2 Year old COMAR
:*:]2yc::
Send Hello,{Enter 2} You are unable to activate this product as the COMAR is over 2 years old. There is a form in the Dealer Corner that you can fill out to have it replaced as long as it falls within the criteria outlined in solution 108357.{Enter}Please contact your TCSM if you have any questions about this process.
Return
; CCMS
:*:]cms::
Send Hello,{Enter 2} {Enter}{Home down}{Shift up}{Home up}Please contact us if you have any questions.{Enter 2}Thank you,{Enter}David{Up 4}{End}
Return
#If
; German
#If, ger = "1"
; Regular
:*:[email::
Send Hallo,{Enter 2} {Shift down}{Enter}{Shift up}Für Rückfragen stehen wir gerne zur Verfügung.{Up}{End}
Return
; DTAC Problem
:*:[97010::
Send Hallo,{Enter 2} Da dies eine Hardware/Kompatibilität-bezogene Anfrage ist, können wir hier im GSC leider ihre Frage nicht sehr gut beantworten. Bitte wenden Sie sich an DTAC, dort können Sie bessere unterstützung für diesen typ von fragen bekommen.
Return
; 2 Year old COMAR
:*:[2yc::
Send Hallo,{Enter 2} Sie können dieses Produkt nicht aktivieren weil die COMAR-Nummer über 2 Yahre alt ist. Es gibt in Vertriebspartnerinformation ein Formular das Sie ausfüllen können, und Ihre Aktivierungen werden ersetzt so lange es innerhalb der Regeln in DTAC Lösung 108357 ist.{Enter}Bitte melden Sie sich bei Ihrem Technischen Bezirksleiter wenn Sie Fragen über diesen Prozess haben.
Return
; CCMS case
:*:[cms::
Send Hallo,{Enter 2} {Enter}{Home down}{Shift up}{Home up}Für Rückfragen stehen wir gerne zur Verfügung.{Enter 2}Mit freundlichen Grüßen,{Enter}David{Up 4}{End}
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
;------------------------------------------------------------------------------
; Symbols, these only replaced when an end character is typed afterwards
#If, symb = "1"
::(deg)::{ASC 248}
::(eq)::{ASC 247}
#If
#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
:*:]jdlw::JDLink Web
:*:]jdld::JDLink Dashboard
:*:]jdl2::JDLink Dashboard 2.0
:*:]jdlc::JDLink Connect
:*:]jdla::JDLink Access
:*:]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
:*:]operm::Operator's Manual
:*:]hl3::HarvestLab 3000
:*:]hlo::Original HarvestLab
:*:]bin::Virtual Inventory
:*:]warrep::Warranty Reports
:*:]tp::TouchPoint
:*:]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
::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::VIN
::gs2::GS2
::gs3::GS3
::sf1::SF1
::sf2::SF2
::sf3::SF3
::sf4::SF4
::xid::xID
::pmcalc::PMCalc
::vat::VAT
; German
#If, ger = "1"
:*:[at::AutoTrac
:*:[sf::StarFire
:*:[jdlw::JDLink Web
:*:[jdld::JDLink Dashboard
:*:[jdl2::JDLink Dashboard 2.0
:*:[jdlc::JDLink Connect
:*:[jdla::JDLink Access
:*:[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
#If
;------------------------------------------------------------------------------
; QoL Improvements
;------------------------------------------------------------------------------
#j::
Run, C:\Users\%racf%\Downloads ; Open the downloads folder on Win+J
Return
#w::
if WinActive("ahk_exe Explorer.EXE") ; If windows explorer is focused
{
Send !d ; Focus the address bar
Send C:\Users\%racf%\Documents\Work_Docs\Cases\2019-07 - 12 ; current folder, would love to use a var instead, but Run doesn't like it
Send {Enter}
Return
}
Run, C:\Users\%racf%\Documents\Work_Docs\Cases\2019-07 - 12 ; Open the documentation folder on Win+W
Return