The way I wrote the script, you don´t have to call the mapkey "ptrail" manually, it´s automatic. But, from the info you gave to me, that isn´t happening in your computer. It seems that for for reason, the script calls the first mapkey again ("trail"), it losses the "p" somewhere in the way.
If you want to break the loop, rename the mapkeys as I suggested, and then it will work in two steps:
1st - Call mapkey "t1" to create txa file
2nd - Call mapkey "t2" to play txa file
Jose