How to make custom code for screenshot, target could be web application/ Desktop application or Session

I want to make custom code for screenshot, target could be web application/ Desktop application or Session. So for take screenshot activity how can i pass these 3 different selectors for 3 different applications to make the workflow customize so that it could be used anywhere.

Thanks