This is, instead of pressing the F6, the user checks a checkbox (named vserial) in a gui interface (which has someother stuff that would not interfere with the serial function) and, after pressing an OK button (submitting the whole set of options made), the script should start to work.
The issue now is the following: I want to replace the instruction to start the script, which now starts work with F6 key, with an instruction coming from a gui interface. The script you posted works like a charm and I was able to customize it. Sorry for any inconvenience, but I'll bother you once again with (I hope) just a simple question.