How to prevent accidental keystrokes while macro is running

I happen to use a little app called Palua. It sits in your menu bar and allows you to toggle back and forth easily between Function Mode and Apple Mode. When you are in Apple Mode the function keys have a default behavior and do things like pushing the volume up and down or brighten/dim the screen. So in Apple Mode, those function keys will not interfere with your macro.

If you hold down the fn key before you hit the function key then they become "classic" function keys and can do whatever you want. In my world, they are common triggers for Keyboard Maestro scripts.

It can be annoying to always have to hold down the fn key. To avoid this, you can put the function keys into Function Mode. In this mode, they no longer invoke the Apple Mode functions. They just await your personal use. Basically, the function keys start acting as if you were holding down the fn key.

Palua comes with a toggle key combination that toggles between Function Mode and Apple Mode. So it is easy in a Keyboard Maestro script to put it into Apple Mode when you want it to be "unresponsive" and then immediately before it is time for you to provide your input, put it into Function Mode.

As I prepared this Reply, I find that Palua is no longer available (It was a $1.00 app). I have had it forever and it still works with Mojave which is what I use. I love the app and there are some murmurings that its disappearance is "temporary" but I would not put too much stock in that. It apparently has been out of the App store for years. I found a discussion in the forum ( Toggling F-Keys) that discusses approaches to this problem without using Palua. Someone provided an AppleScript to do this. I am surprised that this is as complicated as it is, but I presume you could copy that AppleScript.

You can go to System Preferences/Keyboard and click/unclick a checkbox to Use F1, F2, etc. keys as standard function keys. If you did not want to use AppleScript, you might be able to use Keyboard Maestro to navigate to this location and click/unclick this checkbox but that might be a little elaborate in itself.

I do not have a laptop with a Touch Bar but apparently you can arrange it that when a certain app is running the function keys show up in the Touch Bar. https://support.apple.com/en-us/HT207240. I cannot test this but if the app running your actions 1-10 does nothing untoward when you type on a function key, you could make these function keys available and they would do nothing unless you had moved into a place in your macro that they had an effect.