In transaction SE38/SE80 I would like to mark a part of the source code using the mouse, and then process the marked part in an InputScript. Is this possible?

Yes, if the user presses Ctrl+V after marking the text. You can then use the command 

CopyText  toText="T1"   -fromClipboard

to put the marked text into a text variable.