I use Automate to interact with a given app when it's in the foreground, however the "App in foreground" block doesn't always update correctly when using floating windows.
For testing, I use a simple automate task that does an infinite loop of "when foreground app (when changed)" and then...