Is this topic any use to you?
I don’t think it’s exactly what you’re after, but you may be able to amend it to target what you need?