The Screenshot Service Extension is able to capture a screenshot while your app is not running. Minimum API level is 21 (Android 5).
For details, example projects and documentation see here https://puravidaapps.com/screenshotservice.php
What does the user see?
After starting the service the capturing app will display the following "ugly" dialog to the user depending on the Android version... (below Android 10 this dialog is less ugly )
The user must tap "Start Now" and a permanent notification will be displayed in the status bar for the user to start capturing a screenshot or shutdown the service.
For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.