Foreground window errors are often related to screen lock being on, especially if global clicks are required (which is usually the case with Active Accessibility).
Also, where you are using global clicks, are you first activating the application main window - with a tiny wait to give the window time to become active?
Are your virtual pc's set up in accordance with the Blue Prism infastructure guides (you should not be using rdp to connect/disconnect as the screen will not exist after you disconnect) and Is the screenlock on your virtual PC disabled?