You can get the foreground app name magic text (written as [fg_app_name]) 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. See also : Foreground app package