I am currently testing Keyboard Maestro and wrote a macro that
- opens the journaling application Day One
- creates a new entry
- inserts a few line of standard text
This macro worked for two days now with the expected results. Now it doesn't work properly anymore: Day One is opened but no new entry is created. Any ideas?
I added another 0.5 second pause and until now it seems to work on every occasion. Why is this delay (now) necessary?
I can't explain why you need to include a delay in this macro now, but I can point you to a much better way of accomplishing your goal: installing the Day One command-line tool and creating new entries with pre-defined text via the Execute a Shell Script action (IMPORTANT: you'll need to make sure that you have an environment variable properly set up in KM before the
dayone2 command will work, so make sure to read the "Setting the ENV_PATH Keyboard Maestro Variable" section of the "Execute a Shell Script" page linked above):
Not only is this method faster and more reliable, Day One doesn't even have to be open for it to work. I encourage you to give it a try; if you run into problems, feel free to report back with further questions.
EDIT: I remembered that Day One also has a URL scheme, so if you don't feel comfortable with the command-line tool, you could also do something like this:
Unfortunately, this method doesn't let you add new entries even while Day One is closed like the command-line tool does, but it will reliably launch Day One for you if it isn't open already, so it should still be an improvement over the method you're using now.
The initial Pause Until is unnecessary since the Activate action waits for Day One to be at the front anyway.
However just being at the front does not necessarily mean the application is entirely ready to be interacted with. This is especially the case if the application is being launched. It may be at the front, but the application may not have fully initialised itself, or created its initial window or opened existing documents or whatever.
Also, after typing Command-N, presumably the application will open a new document, and that could take a while and so the Insert Text by Pasting could end up pasting into the non-existent (or previously opened) document instead.
So what you might have instead would be:
Activate Day One
Pause Until File ➤ New Document is enabled
Pause Until Front Window title contains "Untitled Document"
Insert Text by Pasting.
(this is just an example, I don't have Day One, so I have no idea what the File menu holds or what it calls newly created documents).
Thank you for your help and clarifying comments. For now, I will go with the pause solution, but I am sure the macro evolves as I learn more about Keyboard Maestro.