I want the following macro to send me an email when a timer ends, but it’s not working. My screenshot shows what the timer looks like and the time.txt file the macro generates recording its value every minute based on the OCR action (I define the OCR area just before running the macro).
Here’s a gif of the timer as it changes. But I only OCR the portion of the screen with the changing numbers (shown as the red box). And those change format as time goes beyond seconds to minutes to hours; ie, from format ss.sss, to mm:ss.sss, to hh:mm:ss.sss
The macro below shows that I tried using Try/Catch and also an If/then statement to catch the error which appears when the timer ends. But it never sends me an email, even though when I test the email action alone, it works (of course, with a real email address inserted)
How can I get this to send me an email when the timer stops? By the way, the timer is from the Subtitle Edit app’s Whisper transcribe feature, which can take hours and that’s why I want to be notified when it ends.
What exactly you try to recognize by OCR, is it the text file? Why not read this text file directly? As always in this forum, better to describe the process and your needs than asking why something doesn’t work.
As I wrote the .txt file is generated by my macro, specifically in the “Append Text to File” action. That text in turn is generated by the OCR action which captures the portion of the screen where the timer is changing.
In other words, I have an app that shows a timer and I want to have an email sent to me when that timer is finished since it takes hours. The elapsed time is recorded every minute in the .txt file I generate, so I when I come back to the computer after it finishes I can see from the last entry when it finished. But I want it to email me when it finishes so I know when to come back to the computer.
I hope that’s better. I’m trying to be as clear as I can.
You are capturing the entire area rather than the last row of the OCR area?
No, I’m only capturing the area shown by the red box in my diagram; ie, just the changing time
It's ridiculously early here (love those airport runs!), but couldn't you simplify this:
You're already recording (some value) to a text file every minute. Assuming that value always changes within that minute if the OCR is still happening, why not use two variables instead:
Set old_timer to 0
start repeat loop that does stuff that generates timer values
set new_timer to value from thing
if new_timer = old_timer
comment: Timer hasn't changed, so job is done
send email
exit loop
else
set old_timer to new_timer
repeat
Wouldn't that do what you want it to do? Again, apologies for any gross logic errors, as I shouldn't be awake right now :).
At the bottom of my text.txt file image, it shows what happens when the timer stops: an OCR error “Warning: Invalid resolution 0 dpi. Using 70 instead.” I’m assuming that’s what happens when it sees pure white rather than text?
In any event, the timer disappears so you don’t have the same value written over and over to the txt file. That .txt file is just a record of what the OCR action gathered.
I suppose I could test for that warning text, but I don’t really understand it and figured there must be a better way
I’ve tried using if local_time “is empty” in my If All Conditions met action but I still didn’t get an email. I double check and I do get an email if I use gear>Try Action
regarding RexEx, I’m not that good at it but am working on getting the correct string right now
I'm confused: Why do you need regex? Just check if the variable contains "Warning." That value is getting written to the file, which means it must be stored in the variable, right?
@griffman I agree with you that I could check for the word “warning” in the text file that I'm making. But I think that's relying on the screen area that I chose for capturing not having any valid text in it. again as I mentioned earlier, I'm not exactly sure about what that warning message means so this is just my best guess.
I think the weakest part of my whole approach here is that portion of the screen with the timer, is subject to being covered up by changing windows or even changing workspaces. What I like about checking the timer format with rejects is that it's a strict test that I understand rather than relying on some warning that I don't understand
@Joel I'm confused by your question. Let's use the example I gave in my screenshot:
31.278
1:31.379
2:31.579
3:31.679
Warning: Invalid resolution O dpi. Using 70 instead.
The first timer value is captured by OCR, put into a variable, which is then written to the .txt file and a minute passes. Then the second timer value is captured by OCR, etc... until the OCR capture step results in an error and somehow is written to the text file. Like I've said, I don't really understand that part.
Is the variable actually holding that text? Or is it an error generated somewhere, perhaps before the variable is assigned -- after all, it's the OCR step that's causing problems, right? I see in the gear to that action that "Failure Aborts Macro" and "Notify on Failure" are checked. Maybe I'm seeing the notice? But why isn't the macro failing? The macro just kept going on and on
So, I hope you can see that given my state of uncertainty about what's going on here, it seems odd for me to rely on this error appearing in the text file in a certain way. Also, I've seen other text appear in this file when I allowed windows to cover that part of the screen and that makes me nervous because I can't predict it. On the other hand, ensuring the OCR'd text has a certain format seems pretty predictable.
@Tony I at the gym now but can build something later for you.
I was responding to your comment that the window gets obscured.
I was suggesting foregoing the OCR route and reading the text file into Keyboard Maestro which is done by one action.
Once the fine is in Keyboard Maestro you can proceed using the current RegEx, a simpler RegEx as @griffman suggested on WARNING, or other way.
One idea I would add is to only read the fine when the export is fine. You can do that by using an UNTIL loop and testing the file size that way you read the file only when the text file is no longer being update and get an e-mail report.
@Joel - but this is only waiting for finishing process of generation the new file (subtitles file) which will appear in selected folder when process will be finished. No generating the text wile with status, no needs to read the file with the status, just only wait the file will be created and let the operating system notify tools which observe this folder and let them work (notif, send mail and other things). It can be done even with Automator.