Since Minecraft’s release (and I believe since its creation), there was a bug that allowed you a to repeatedly input a command. I’ve seen it called the “afk bug”, “F11 bug”, or “alt tab bug”.
Basically, you held down some key(s) and pressed f11 to toggle between windowed and full screen. Then the command would continue to be input. This command would persist to be input even after you alt tab to something else. Honestly, I almost thought it was a feature.
But 1.13 fixed my “feature” that I used mainly for fishing and cobblestone.
How can I AFK click in Minecraft post 1.13 (Java Edition)?
In 1.14, there is a way to afk fish that means you can alt-tab out. You point and press with the mouse, and then unplug the mouse. This provides an autoclick that will work as an afk fisher. However, if you want to then leave Minecraft, you can reload the texture packs, (fn + F3 + T for Windows, cmd + fn + F3 + T for Mac) and then, while the packs are reloading, alt-tab out. Then, you can alt-tab in and out, no issues. Minecraft will still believe you are clicking, when in reality, you can be playing another game, or watching YouTube, or really anything else. In fact, I just did this while typing out this answer.