concerning the first part: i would do it with ui interactions till you copy it on your clipboard and then write your clipboard in a string variable.
about the second part: i need to think about, but first i go to bed. i don't know how much time i will have tomorrow, maybe someone else has more experience, i will need to test the possibilities aswell.