Files
d3k/D3K.ahk
T

402 lines
12 KiB
AutoHotkey
Raw Normal View History

2026-08-28 12:17:30 -05:00
#Include "func.ahk"
#Include Peep.v2.ahk
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
DetectHiddenWindows true
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
A_TrayMenu.Add("&Mouse Mover", MsMv) ; Add item to the tray to move the mouse
A_TrayMenu.Add("&Settings", D3K_Settings) ; Add item to the tray for the settings window
A_TrayMenu.Add(A_AhkVersion, docs)
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
; Global Variables
;------------------------------------------------------------------------------
2026-08-28 12:17:30 -05:00
If (settings["GloVar"])
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:17:30 -05:00
global glovarini := A_MyDocuments "\GloVar.ini" ; Location of the ini that the user modifies
global gvMod := FileGetTime(glovarini)
SetTimer(GloVar, 2000) ; Check every 2 seconds
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
GloVar(*){
If !(WinActive("GloVar.ini")){ ; Only run when the window isn't active, prevents accidential editing by the script while the user is editing
gvModNew := FileGetTime(glovarini)
2023-07-14 10:27:33 -05:00
If !(gvModNew = gvMod) ; Those two lines mean the rest of this only executes if there were changes to the ini.
{
2026-08-28 12:17:30 -05:00
glovarscript := A_Temp "\GloVar.ahk" ; self-contained, no reference to any other AHK scripts
glovarstart := "#Requires AutoHotkey v2`n#SingleInstance force`n#NoTrayIcon`n"
hotstrings := "" ; Stop ahk from complaining about it not having a value. Just ignore it bro
SetTimer(GloVar, 0) ; Stop the timer while we work on the file
glovar_map := ini_load(glovarini)
For section in glovar_map {
For key, value in glovar_map[section]
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:17:30 -05:00
Switch section, 0
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:17:30 -05:00
Case "Serial Numbers":
value := StrUpper(value) ; Makes it uppercase
ini_write(glovarini, key, value)
Case "Info":
If (key = "case")
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:17:30 -05:00
value := StrUpper(value) ; Makes it uppercase, just in case it was manually typed
ini_write(glovarini, key, value) ; Writes the properly formatted case number to glovar.ini
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:17:30 -05:00
Case "Clear": ; Will clear the ini and save its and the documentation file's contents to a log
temp := FileOpen(settings["DocFile"], "r")
doctemp := temp.Read()
temp.Close()
temp := FileOpen(glovarini, "r")
initemp := temp.Read()
temp.Close()
initemp := RegExReplace(initemp, "i)(?<=\[)clear(?=\])", "Info") ; Replace the "clear" section we set with Info, case insensitive
temp := FileOpen(A_MyDocuments "/D3KLog.txt", "a")
writethis := "Case on " FormatTime(A_NowUTC, "yyyy-MM-dd") "`n`n" doctemp "`n`n" initemp ; Save the current time, what was in the doc file, and glovarini to a variable
temp.Write("`n`n" writethis "`n`n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
temp.Close()
temp := FileOpen("glovarsource", "r")
glovarsource := temp.Read()
temp.Close()
temp := FileOpen(glovarini, "w")
temp.Write(glovarsource) ; Overwrite .ini for a clean slate
temp.Close()
temp := FileOpen(settings["DocFile"], "w") ; Overwrites documentation for a clean slate
temp.Close()
script := FileOpen(glovarscript, "w")
script.Encoding := "UTF-8"
script.Write(glovarstart)
script.Close()
Run(glovarscript) ; Just in case. Don't want an old version running.
ToolTip("Cleared")
Sleep(500)
ToolTip()
global gvMod := FileGetTime(glovarini) ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
SetTimer(GloVar, 2000) ; Check every 2 seconds
Return
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:17:30 -05:00
If (value){ ; skip trying to write a hotstring that doesn't do anything
hotstrings .= "`n:*:$" key "::" value
}
}}
If (hotstrings){ ; skip trying to write to the file if there aren't any hotstrings (as in any time it's cleared)
script := FileOpen(glovarscript, "w")
script.Write(glovarstart hotstrings)
script.Close()
Run(A_AhkPath " " glovarscript)
ToolTip("GloVars updated")
Sleep(500)
ToolTip()
}
global gvMod := FileGetTime(glovarini) ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
SetTimer(GloVar, 2000) ; Check every 2 seconds
If (settings["msmv"] = "no-running" or settings["msmv"] = "yes-running") ; might as well update the checkboxes in the menu
{
A_TrayMenu.Check("&Mouse Mover")
} else { ; have to include ampersand to refer to it by name!
A_TrayMenu.UnCheck("&Mouse Mover")
2023-07-14 10:27:33 -05:00
}
}
2026-08-28 12:17:30 -05:00
}}
2023-07-14 10:27:33 -05:00
Return
}
;------------------------------------------------------------------------------
; Settings window
;------------------------------------------------------------------------------
2026-08-28 12:17:30 -05:00
!+\::D3K_Settings() ; Alt+Shift+\
D3K_Settings(*)
{
Run("Settings.ahk")
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
docs(*){
Run("https://www.autohotkey.com/docs/AutoHotkey.htm")
}
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
2026-08-28 12:17:30 -05:00
; Mouse Mover todo: autostart
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
2026-08-28 12:17:30 -05:00
MsMv(ItemName, ItemPos, MyMenu)
{
settings := ini_load(sett_ini)
switch settings["msmv"] { ; couldn't find a good way to detect if it's running or not so now we have this.
case "always-running": ; run at refresh of d3k. if currently running, stop
Run A_ScriptDir "\msmv.ahk off"
MyMenu.Uncheck(ItemName)
ini_write(sett_ini, "msmv", "always-stopped")
case "always-stopped": ; run at refresh, currently stopped. if currently stopped, start
Run A_ScriptDir "\msmv.ahk on"
MyMenu.Check(ItemName)
ini_write(sett_ini, "msmv", "always-running")
case "no-running": ; don't run at refresh, currently running. if currently running, stop
Run A_ScriptDir "\msmv.ahk off"
MyMenu.Uncheck(ItemName)
ini_write(sett_ini, "msmv", "no-stopped")
case "no-stopped": ; don't run at refresh, currently stopped. if currently stopped, start
Run A_ScriptDir "\msmv.ahk on"
MyMenu.Check(ItemName)
ini_write(sett_ini, "msmv", "no-running")
default:
MsgBox("Unexpected value `"" settings["msmv"] "`" in D3Ksettings.ini")
Reload
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:17:30 -05:00
}
cleanup(*) ; to make sure msmv closes when we close d3k
{
settings := ini_load(sett_ini)
switch settings["msmv"] { ; couldn't find a good way to detect if it's running or not so now we have this.
case "always-running": ; run at refresh of d3k. if currently running, stop
Run A_ScriptDir "\msmv.ahk off"
ini_write(sett_ini, "msmv", "always-stopped")
case "no-running": ; don't run at refresh, currently running. if currently running, stop
Run A_ScriptDir "\msmv.ahk off"
ini_write(sett_ini, "msmv", "no-stopped")
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:17:30 -05:00
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
OnExit cleanup
2023-07-14 10:27:33 -05:00
;-------------------------------------------------------------------------------
; Capitalise dates
;-------------------------------------------------------------------------------
::monday::Monday
::tuesday::Tuesday
::wednesday::Wednesday
::thursday::Thursday
::friday::Friday
::saturday::Saturday
::sunday::Sunday
::january::January
::february::February
::april::April
::june::June
::july::July
::august::August
::september::September
::october::October
::november::November
::december::December
; German
2026-08-28 12:17:30 -05:00
#HotIf (settings["German"])
2023-07-14 10:27:33 -05:00
::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
2026-08-28 12:17:30 -05:00
#HotIf
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
; Email
;------------------------------------------------------------------------------
:*:]email::
2026-08-28 12:17:30 -05:00
{
Send "Hello,{Enter 2}{Space 3}"
}
2023-07-14 10:27:33 -05:00
; German
2026-08-28 12:17:30 -05:00
#HotIf (settings["German"])
:*:[email::{
Send "Hallo,{Enter 2}{Space 3}"
}
#HotIf
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
; 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
#v::
2026-08-28 12:17:30 -05:00
{
Sleep(750)
SendInput(A_Clipboard)
}
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
; Common Terms autocorrect and replacement
;------------------------------------------------------------------------------
2026-08-28 12:17:30 -05:00
#HotIf (settings["JDProductNames"])
2023-07-14 10:27:33 -05:00
; English
:*:]at::AutoTrac
2026-08-28 12:17:30 -05:00
:*:]bna::Basics & AutoTrac
:*:]bfs::Basics for Services
:*:]bas::Basics, AutoTrac, and Section Control
:*:]jlb::JDLink Boost
2023-07-14 10:27:33 -05:00
:*:]jdp::JDParts
:*:]mjd::MyJohnDeere
:*:]opsc::Operations Center
:*:]seccon::Section Control
:*:]gs::GreenStar
:*:]cc::CommandCenter
:*:]fc::Field Connect
:*:]rs::RowSense
:*:]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
:*:]jdsm::John Deere Software Manager
:*:]jddm::John Deere Data Manager
:*:]serva::Service Advisor
:*:]muc::Master Unlock Code
:*:]bsm::Base Station Manager
2026-08-28 12:17:30 -05:00
:*:]lm::License Manager
:*:]sns::See & Spray
:*:]s4::SF-RTK
:*:]ls::licenses
:*:]sub::subscription
:*:]agt::AgTech Code
2023-07-14 10:27:33 -05:00
::rowsense::RowSense
2026-08-28 12:17:30 -05:00
::comar::COMAR
::comars::COMARs
2023-07-14 10:27:33 -05:00
::mrtk::mRTK
::rda::RDA
::rtk::RTK
::autotrac::AutoTrac
2026-08-28 12:17:30 -05:00
::ccms::CCMS
::dtac::DTAC
2023-07-14 10:27:33 -05:00
::tcsm::TCSM
::itec::iTEC Pro
::ssu::SSU
::atu::ATU
2026-08-28 12:17:30 -05:00
:*:mtg::modem
2023-07-14 10:27:33 -05:00
::itc::iTC
2026-08-28 12:17:30 -05:00
::vin::Machine PIN ; Not actually vehicles, so they don't have VINs
2023-07-14 10:27:33 -05:00
::gs2::GS2
::gs3::GS3
2026-08-28 12:17:30 -05:00
::g4::G4
::g5::G5
2023-07-14 10:27:33 -05:00
::sf1::SF1
::sf2::SF2
::sf3::SF3
::xid::xID
::pmcalc::PMCalc
2026-08-28 12:17:30 -05:00
::VAT::VAT
::RACF::RACF
2023-07-14 10:27:33 -05:00
::igrade::iGrade
2026-08-28 12:17:30 -05:00
::ISOBUS::ISOBUS
::JDCP::JDCP
::LORT::LORT
::ISG::ISG
2023-07-14 10:27:33 -05:00
; German
2026-08-28 12:17:30 -05:00
#HotIf (settings["German"])
2023-07-14 10:27:33 -05:00
:*:[at::AutoTrac
2026-08-28 12:17:30 -05:00
:*:[bna::Basics & AutoTrac
:*:[bfs::Basics for Services
:*:[bas::Basics, AutoTrac, and Section Control
:*:[sf4::SF-RTK
:*:[jlb::JDLink Boost
2023-07-14 10:27:33 -05:00
:*:[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
:*:[tcsm::Technischer Bezirksleiter
:*:[jdsm::John Deere Software Manager
:*:[jddm::John Deere Data Manager
:*:[serva::Service Advisor
:*:[muc::Master Unlock Code
:*:[asmn::Asset Manager
:*:[bsm::Base Station Manager
2026-08-28 12:17:30 -05:00
:*:[lm::License Manager
:*:[sns::See & Spray
:*:[s4::SF-RTK
:*:[ls::Lizenz
:*:[agt::AgTech Code
#HotIf
2023-07-14 10:27:33 -05:00
;------------------------------------------------------------------------------
; QoL Improvements
;------------------------------------------------------------------------------
:*:]me::
:*:[me::
2026-08-28 12:17:30 -05:00
{
Send StrUpper(A_UserName)
}
2023-07-14 10:27:33 -05:00
2023-07-17 12:30:38 -05:00
2026-08-28 12:17:30 -05:00
#HotIf !(settings["Email"] = "[email protected]")
:*:@em::
{
SendInput(settings["Email"])
}
#HotIf
; Open the downloads folder on Win+J
#j::Run("C:\Users\" A_UserName "\Downloads")
2023-07-14 10:27:33 -05:00
:*:[now::
:*:]now::
2026-08-28 12:17:30 -05:00
{
SendInput(FormatTime(A_NowUTC, "yyyy-MM-dd") "T" FormatTime(A_NowUTC, "H:mm'Z'")) ; Send the current time & date in ISO8601 format
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
; Send the current date in ISO8601 format
2023-07-14 10:27:33 -05:00
:*:[today::
:*:]today::
2026-08-28 12:17:30 -05:00
{
SendInput(FormatTime(A_NowUTC, "yyyy-MM-dd"))
}
2023-07-14 10:27:33 -05:00
:*:[deg::{ASC 248}
:*:]deg::{ASC 248}
:*:[eq::{ASC 247}
:*:]eq::{ASC 247}
2026-08-28 12:17:30 -05:00
:*:[shrug::
:*:]shrug::
{
SendInput("¯\_(ツ)_/¯ ") ; Somehow the space at the end is very important
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
:*:[pwd::
:*:]pwd::
{
Send "{AppsKey}"
Sleep(100)
Send "{Up}"
Sleep(50)
Send "{Enter}"
Sleep(50)
Send "{Enter}"
Sleep(100)
Send "{Enter}"
Sleep(750)
Send "{Enter}"
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:17:30 -05:00
F19::Reload