You can get the foreground app package magic text (written as [fg_app_package]) to get the current opened app. This can have some issue with overlays but it should be fixed in v5.38 and above. To use this magic text, you will need to grant accessibility permission to MacroDroid otherwise "?" will be returned. You can for example use this to launch the previous opened app after you have launched another app to modify something with a macro. See also : Foreground app name