fix looping bug
Changed to reading the time the file was last modified instead of its contents, much more reliable. Thanks nou on the AHK discord for the help!
This commit is contained in:
parent
a3c9c9ed1b
commit
31751b4066
29
D3K.ahk
29
D3K.ahk
@ -1,7 +1,5 @@
|
|||||||
#Include, func.ahk
|
#Include, func.ahk
|
||||||
|
|
||||||
lastFileContent =
|
|
||||||
|
|
||||||
Menu, Tray, Icon, shell32.dll, 283 ; Set the tray icon to a keyboard
|
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
|
SetWorkingDir, %A_MyDocuments%\D3K ; Make sure we can find the .ahks linked below
|
||||||
@ -73,21 +71,15 @@ If (glovar = 1)
|
|||||||
SetTimer, GloVar, 2000 ; Check every 2 seconds
|
SetTimer, GloVar, 2000 ; Check every 2 seconds
|
||||||
|
|
||||||
GloVar:
|
GloVar:
|
||||||
If FileExist("glovar.ahk")
|
|
||||||
{
|
|
||||||
Run glovar.ahk
|
|
||||||
}
|
|
||||||
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
|
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
|
||||||
{
|
{
|
||||||
fileread, newFileContent, %glovarini%
|
FileGetTime, gvModNew, %glovarini%
|
||||||
if !(newFileContent = lastFileContent) ; Those two lines mean the rest of this only executes if there were changes to the ini.
|
if !(gvModNew = gvMod) ; Those two lines mean the rest of this only executes if there were changes to the ini.
|
||||||
{
|
{
|
||||||
lastFileContent := newFileContent
|
gvMod := gvModNew
|
||||||
FileDelete, glovar.ahk ; Start with a clean slate
|
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, #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
|
RESection := "" ; Make sure that its clear
|
||||||
|
|
||||||
Loop, Read, %glovarini% ; Read one line at a time
|
Loop, Read, %glovarini% ; Read one line at a time
|
||||||
@ -107,7 +99,7 @@ GloVar:
|
|||||||
WinWaitNotActive, GloVar.ini ; Just to make sure
|
WinWaitNotActive, GloVar.ini ; Just to make sure
|
||||||
{
|
{
|
||||||
ini_writeValue(glovarini, REKey, REValue)
|
ini_writeValue(glovarini, REKey, REValue)
|
||||||
fileread, lastFileContent, %glovarini%
|
FileGetTime, gvMod, %glovarini%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
If InStr(StoredSection, "Operations Center") ; If the section is "Operations Center" and the Key "un", make it uppercase
|
If InStr(StoredSection, "Operations Center") ; If the section is "Operations Center" and the Key "un", make it uppercase
|
||||||
@ -118,7 +110,7 @@ GloVar:
|
|||||||
WinWaitNotActive, GloVar.ini
|
WinWaitNotActive, GloVar.ini
|
||||||
{
|
{
|
||||||
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
|
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
|
||||||
fileread, lastFileContent, %glovarini%
|
FileGetTime, gvMod, %glovarini%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,14 +123,14 @@ GloVar:
|
|||||||
WinWaitNotActive, GloVar.ini
|
WinWaitNotActive, GloVar.ini
|
||||||
{
|
{
|
||||||
ini_writeValue(glovarini, REKey, REMatch) ; Writes the properly formatted case number to glovar.ini
|
ini_writeValue(glovarini, REKey, REMatch) ; Writes the properly formatted case number to glovar.ini
|
||||||
fileread, lastFileContent, %glovarini%
|
FileGetTime, gvMod, %glovarini%
|
||||||
}
|
}
|
||||||
REValue := REMatch
|
REValue := REMatch
|
||||||
} Else {
|
} Else {
|
||||||
WinWaitNotActive, GloVar.ini
|
WinWaitNotActive, GloVar.ini
|
||||||
{
|
{
|
||||||
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
|
ini_writeValue(glovarini, REKey, REValue) ; Writes the properly formatted case number to glovar.ini
|
||||||
fileread, lastFileContent, %glovarini%
|
FileGetTime, gvMod, %glovarini%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,8 +147,7 @@ GloVar:
|
|||||||
ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful)
|
ini_writeValue(glovarini, "dus", dealinfo.user) ; Writes demo account name (somewhat useful)
|
||||||
ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase
|
ini_writeValue(glovarini, "xID", REValue) ; Writes the xID entered, but uppercase
|
||||||
}
|
}
|
||||||
fileread, lastFileContent, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
|
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
|
||||||
Break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
If (RESection) ; If we have a section
|
If (RESection) ; If we have a section
|
||||||
@ -171,14 +162,14 @@ GloVar:
|
|||||||
writethis := "Case on " . CurrTime . "`n" . doctemp . "`n`n" . initemp ; Save the current time, what was in the doc file, and glovarini to a variable
|
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
|
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
|
FileCopy, glovarsource, %glovarini%, 1 ; Copies and replaces any text in glovar.ini with the template
|
||||||
fileread, lastFileContent, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
|
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
|
FileDelete, glovar.ahk ; THE CLEAN SLATE
|
||||||
FileAppend, #SingleInstance force`n`n, glovar.ahk
|
FileAppend, #SingleInstance force`n`n, glovar.ahk
|
||||||
Sleep, 500
|
Sleep, 500
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileread, lastFileContent, %glovarini% ; Make sure that this script knows what the ini was changed to so it doesn't constantly run through the above code
|
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")
|
If FileExist("glovar.ahk")
|
||||||
{
|
{
|
||||||
Run glovar.ahk
|
Run glovar.ahk
|
||||||
|
Loading…
Reference in New Issue
Block a user