Is there any way I could hold down the mouse button whilst being tabbed out? My goal is to be able to have multiple windows running at the same time on 1 PC, all of them holding down W and LMB.
Make sure Minecraft doesn't pause when losing focus. You can do this by hitting F3+P.
Once you did that, you can do the input you want to persist and hit F3+T. This will reload your resources. While you see the loading screen release your input. After Minecraft is done reloading, your input should remain active without pressing anything.
This is pretty useful for AFK Fishing in 1.15 and below as you don't need any macros with this trick.