Thanks so much for the quick response @mikeyww! It obviously works now in 3 seconds when I get one of you masters to take a peek. Apologies for my delayed reply. I have absolutely no idea how I never got that to work, because I literally spent hours reading the documentation and trying all the different ways with formattime, EnvSub vs -=, trying to subtract start from end, EnvAdd, += trying to add a negative start time to the end time (As I read was required in several places in forums/docs). It just always came back with a null value. I was ripping my hair out lol and trying not to ask you guys, because I need to figure these things out on my own to improve my limited skill.
mikeyww wrote: ↑12 Jun 2021, 19:30
With your script:
Code: Select all
Noise:
tStart := A_Now
MsgBox, Alert is active at %tStart%.
tEnd := A_Now
tElapsed := tEnd
tElapsed -= tStart, seconds
MsgBox, %tElapsed% seconds passed between alert and acknowledgement.
Return
Your question about A_Now is readily answered by doing a short test. It is the instantaneous timestamp and will not be updated if you save it to a variable.
I actually did try that. When I started getting my first nulls, I realized I probably needed to assign a variable to it, and set up a test similar to what you showed, but I was probably still mistakenly trying to "add" a negative start date/time.
So it looks like creating the negative date is what did me in. I just needed to change += -start to -= start. Do I understand that right?
I have one more question if you don't mind.
Code: Select all
tEnd := A_Now
[color=#FF0000],[/color]tElapsed := tEnd
My understanding of AHK is that it takes about 10ms to execute each line. I was afraid of a slight time difference stored between the tEnd & tElapsed variable. From what I read, placing the comma in front of the 2nd line, should cause them to be executed together rather than sequentially. Is that correct?
If so, I see now, that it was not only unnecessary, since tElapsed was assigned to tEnd anyway, so it doesn't matter even if there was a time difference between when both lines were executed. If fact, would that even store anything in the second variable if they were executed at the same time?