try this. I misunderstood what you wanted to do... there is a function which checks if you are in the background. You may need to play with the first sleep to ensure you are in the bg. or have a loop that sleeps while not in background, then second that sleeps while it is..

import console,time #launch you app time.sleep(1) while console.is_in_background(): time.sleep(1) #launch your app time.sleep(1) while console.is_in_background(): time.sleep(1)