From ae88cc6394f7e988cf6c0777e3a88ef2c213f789 Mon Sep 17 00:00:00 2001 From: David Daily Date: Thu, 9 Jan 2020 06:58:36 -0600 Subject: [PATCH] Fixing lookup behaviour It used to look up the xID and related info from the CSV and put it in the ini, but glovar.ahk was never updated with the new info. This replaces that whole thing with regexreplace, similar to the ini function that I wrote in func.ahk --- D3K.ahk | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/D3K.ahk b/D3K.ahk index 5c71b09..1bed5f1 100644 --- a/D3K.ahk +++ b/D3K.ahk @@ -68,6 +68,8 @@ If (glovar = 1) { glovarini = %A_MyDocuments%\GloVar.ini ; Location of the ini that the user modifies + glovarstart := "#SingleInstance force`n`n:*:$dus::`n:*:$dnm::`n:*:$dem::`n:*:$xid::`n" + SetTimer, GloVar, 2000 ; Check every 2 seconds GloVar: @@ -78,7 +80,7 @@ If (glovar = 1) { 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 + FileAppend, %glovarstart%, 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 @@ -137,6 +139,23 @@ If (glovar = 1) { dealinfo := GetInfo(REValue) ; Gets information, see function for details StringUpper, REValue, REValue ; Makes xID uppercase + + if !(REValue = dealinfo.xid) + { + run addemail.ahk + Break + } + + ; Replace the data in glovar.ahk with the data from the ini + FileRead, tempglovar, glovar.ahk + tempglovar := RegExReplace(tempglovar, "(?<=\$dem::).*", dealinfo.email) + tempglovar := RegExReplace(tempglovar, "(?<=\$dnm::).*", dealinfo.name) + tempglovar := RegExReplace(tempglovar, "(?<=\$dus::).*", dealinfo.user) + tempglovar := RegExReplace(tempglovar, "(?<=\$xid::).*", dealinfo.xid) + FileAppend, %tempglovar%, tempglovar + FileCopy, tempglovar, glovar.ahk,1 + FileDelete, tempglovar + WinWaitNotActive, GloVar.ini { ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase @@ -145,6 +164,12 @@ If (glovar = 1) 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 + Continue + } + If (InStr(REKey, "dem") or InStr(REKey, "dnm") or InStr(REKey, "dus")) + { + ; Do not process xID related info, that is done above + Continue } writethis := ":*:$" REKey "::" REValue "`n" ; Save the hotstring to a variable FileAppend, %writethis%, glovar.ahk ; Write the variable to glovar.ahk @@ -163,7 +188,7 @@ If (glovar = 1) 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 + 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")