in reply to Re^2: Capture Keystroke
in thread Capture Keystroke

something smelled slightly fishy

What is it that smells fishy? Getting mouse events, manipulating window size and stacking order, recording key strokes - all that are things we do all day long (the latter, for instance: saving those key strokes to a file, e.g. Unnamed.doc). Fishy? Is there more to it than a Pawlow's dog reaction?

Do you have any grounds on which to insinuate criminal energy? Do you know of the OP's purposes?

For myself, I'm capturing all output to any terminal I open, to a file, named after 'begin-end-terminal', via script(1) on UNIX. That way I have a log of all I am doing. Does that sound evil to you?

Replies are listed 'Best First'.
Re^4: Capture Keystroke
by repellent (Priest) on Apr 12, 2009 at 21:53 UTC
    I wasn't insinuating any "criminal energy". That's why I tried/used the word "slightly" :)

    Please see my reply to michbach. I hope you catch my tone of emotion from that node. I want the best for michbach, and to avoid any further knee-jerk thoughts (that I've fallen prey to) from other monks.
Re^4: Capture Keystroke
by Zen (Deacon) on Apr 13, 2009 at 17:28 UTC
    That sounds like something I could use. Is that a module, shmem?

      No, it is a UNIX command, which appeared in BSD 3.0. It spawns your $SHELL and makes a typescript of everything printed to the terminal, including backspaces, terminal control sequences and such. See 'man script'. The script(1) command's STDERR can be directed to a file to record the timing of all that appears on the terminal. Of course, anything typed while the terminal is in '-echo' mode won't appear (e.g. passwords). The script file and the timing file can be used to replay the captured outout. Joey Hess wrote a public domain perl script called scriptreplay which does that.

      On Unix:
      > script Script started, file is typescript > ls -ld /typo^H^H^H^Hetc drwxr-xr-x 117 root root 12288 2009-04-13 16:22 /etc > exit Script done, file is typescript

      and then perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' typescript

      filters the escape codes, and prints this out as-is:

      Script started on Tue 14 Apr 2009 10:48:10 AM PDT > ls -ld /etc drwxr-xr-x 117 root root 12288 2009-04-13 16:22 /etc > exit Script done on Tue 14 Apr 2009 10:48:22 AM PDT