thank you both for your posts. Basically, when I am finished typing the question, I want to press Cmd Enter to press the OK button, and go on the to answer, and when I am finished typing the answer, I want to press Cmd Enter to press the OK button to go to the next question/answer but nothing works. I think that it is because no action are visible to KM while I am typing the question and answer.
Ah, now I think I might be understanding a little bit clearer what you are looking for.
I am on my way out now, but I'm having an idea that something like this might do what you need (but this might come from having asynchronously ran macros a bit on the top of my head these days, and I might be thinking this all wrong):
Two macros, where one of them is run asynchronously and waiting for the key presses. I couldn't get it to work with Press-a-button either, so resolved to click found image.
I am in a bit of a hurry so have not built it fully the way I wanted. I would at the very lest want to add a way for the SUBMACRO to be canceled if the prompt in the calling macro is canceled, but couldn't in this moment get my head around how to ad an OR-condition in addition to the cmd- AND Enter-keys
If you are entering a series of questions-and-answers, why not ask for both (no navigation required) in one prompt and repeat the process until you press the Cancel button?
Each set can be appended to a text file after the variables for each question and answer have been formatted for Markdown (your header and italics and spacing) by Keyboard Maestro.
So you'd enter the text of the question, hit Tab, enter the text of the answer and tap OK (or use a special key chord). That set would be added to a text file with the correct formatting and you'd have a blank form in front of you to add the next set. If you're done, you'd tap Cancel.
Good idea. I am working on it and find that simpler solutions seem better, like working directly in markdown, a keyboard shortcut to insert text #### → I write the question, followed by anot.her shortcut for the answer which types ** followed by the ← key to put the cursor between the two * and I type the answer.
My apologies to you, @Alexander and @Zabobon for making the issue more complex than it was.
All good, and only interesting trying to solve these challenges! Also great to hear that you are on your way to finding a good and simpel solution!
I only cherry picked a very small portion of your challenge to work on, but as I weren’t then able to figure out how to solve how to cancel the Submacro if the Calling macro canceled I've kind of been walking around thinking about it ever since, haha. I am however pleased to say that I where finally able to reach closure here as I now had an epiphany of how to solve it!
Closure by functioning cancel
Prompt for snippet — cmd + return to press OK Macros (v11.0.1)
You can cycle through the two fields and the two buttons using the tab key.
When you hit OK, the pair of text fields are stripped of any extra whitespace (like returns) and formatted for Markdown before being added to a running variable that keeps accumulating pairs until you hit the Cancel button.
When you Cancel, you are prompted for a new file (by default on your Desktop but you can change that in the action), all the pairs are written to the file and the file is opened using the default app for Text files (again, you can change that to something that reads Markdown).
The advantage of this approach is that it automates the formatting task and lets you enter just the questions and answers, never leaving the keyboard (tab to the buttons).