Hi, sorry to revive an old thread, but I ran into a similar focus stealing issue with Minecraft Bedrock in BB mode.
What I discovered is you need to run your AutoHotkey script with the "/RunWith UIA" flag to get it working after the game quits (and you're returned to BB mode).
So, for Application Path (in Additional Apps), you would browse to:
"C:\Program Files\AutoHotkey\UX\AutoHotkeyUX.exe"
And in Application Command-Line Parameters, you would adapt this to point to your AHK script:
"C:\Program Files\AutoHotkey\UX\launcher.ahk" /RunWith UIA "C:\Users\yourusername\path\to\your\ahkscript"
My AHK2 script works when I use this UIA flag, and fails to work without it (at least on my setup).