Code: Select all
csv:=FileOpen("My.csv",2)
Code: Select all
csv:=FileOpen("My.csv",2)
If A_LastError=0
csv.Write("Headers`r`n")
else If A_LastError != 183
csv:=FileOpen("Backup " A_DD A_Hour A_Min " .csv",2)
Then I end it off with csv.Close().
I think this is a result of my computer managing to fall asleep; I haven't tested if the code can still run when sleeping, but I'm pretty sure on the occasions that I wake my computer up (I've set it to never sleep when plugged in) it starts to create these Backup files.
And it creates a series of them until I restart my computer to clear the lock on the main files.
I have researched using Resource Monitor (windows 8/8.1/10 native app apparently) to identify a locked file. But searching the names of these files gets me no results. Searching for a file opened in Excel, as a test, does find the file as locked by Excel. Which means either Resource Monitor is faulty and can't find AHK processes hiding in memory, or something has happened and when AHK's process terminated it did not release the files.
What can I do to ensure AHK releases the lock on the files?