People will be urged to take an online mental health test in a campaign backed by the Dukes and Duchesses of Cambridge and Sussex.