Keystroke logger for Windows

Discussion in 'Python' started by hokieghal99, Aug 22, 2003.

  1. hokieghal99

    hokieghal99 Guest

    Does anyone know of a keystroke logger that has been written in Python
    for Windows machines? I'd like to see such a script and use it as a
    point of reference for a real-time backup project that I'm working on.
    Basically, I'd like to be able to capture all keystrokes from the
    keyboard buffer and write them to a text file so I could reporduce
    emails, documents, etc. in the event of file loss that occurs between
    nightly backups. For example, my boss comes to me, he has deleted an
    email that he was writing... he has been working on the email all day...
    and he expects me to wave a magic wand and bring it back.

    Thanks for any advice, code or pointers. Also, if Python isn't suited
    for this, let me know and I'll look at doing this in c
    hokieghal99, Aug 22, 2003
    #1
    1. Advertising

  2. I found this on the web someplace. It may be relevant.

    # /usr/local/bin/Python
    # Displays the keysym for each KeyPress event as you type
    import Tkinter
    root = Tkinter.Tk()

    root.title("Keysym Logger")

    def reportEvent(event):
    print 'keysym=%s, keysym_num=%s' % (event.keysym, event.keysym_num)

    text = Tkinter.Text(root, width=20, height=5, highlightthickness=2)

    text.bind('<KeyPress>', reportEvent)

    text.pack(expand=1, fill="both")
    text.focus_set()

    root.mainloop()


    "hokieghal99" <> wrote in message
    news:bi66lq$skj$...
    | Does anyone know of a keystroke logger that has been written in Python
    | for Windows machines? I'd like to see such a script and use it as a
    | point of reference for a real-time backup project that I'm working on.
    | Basically, I'd like to be able to capture all keystrokes from the
    | keyboard buffer and write them to a text file so I could reporduce
    | emails, documents, etc. in the event of file loss that occurs between
    | nightly backups. For example, my boss comes to me, he has deleted an
    | email that he was writing... he has been working on the email all day...
    | and he expects me to wave a magic wand and bring it back.
    |
    | Thanks for any advice, code or pointers. Also, if Python isn't suited
    | for this, let me know and I'll look at doing this in c
    |
    Elaine Jackson, Aug 23, 2003
    #2
    1. Advertising

  3. > Does anyone know of a keystroke logger that has been written in Python
    > for Windows machines? I'd like to see such a script and use it as a
    > point of reference for a real-time backup project that I'm working on.
    > Basically, I'd like to be able to capture all keystrokes from the
    > keyboard buffer and write them to a text file so I could reporduce
    > emails, documents, etc. in the event of file loss that occurs between
    > nightly backups. For example, my boss comes to me, he has deleted an
    > email that he was writing... he has been working on the email all day...
    > and he expects me to wave a magic wand and bring it back.
    >
    > Thanks for any advice, code or pointers. Also, if Python isn't suited
    > for this, let me know and I'll look at doing this in c


    I don't think Python would be a good choice for the basic keystroke logging
    utility. A program like this is implemented as a systemwide message hook,
    which is a DLL that is loaded into the address space of *every* application.
    This is a simple piece of code that should be written in C/C++ to keep it
    small.

    There are a number of commercial products that do keystroke logging, but the
    ones I've seen are intended for spying on someone else's computer
    activity--i.e. something your boss might want to put on your computer, not
    something you would want to put on your boss's computer!

    I find the spying orientation of those products rather distasteful, but
    maybe one of them could be used in a more benign way. PC Magazine reviewed
    several of them last year:

    http://www.pcmag.com/article2/0,4149,111820,00.asp

    Some time ago I wrote a similar program for my own use (spying on myself as
    it were). Maybe it would be worth cleaning it up and releasing it as open
    source. It's actually pretty handy. For example, if I see a file on my
    system I don't recognize, I can look back at my log and see what I was
    doing--what program I was running that created that file. But I'd be worried
    about the privacy implications--I wouldn't want my program being used as
    spyware.

    -Mike
    Michael Geary, Aug 23, 2003
    #3
  4. > I don't think Python would be a good choice for the basic keystroke
    logging
    > utility. A program like this is implemented as a systemwide message hook,
    > which is a DLL that is loaded into the address space of *every*

    application.
    > This is a simple piece of code that should be written in C/C++ to keep it
    > small.


    Just adding one (fairly obvious) thought... Even though I wouldn't use
    Python for the low-level systemwide message hook, it would be an excellent
    choice for code that processes the resulting log.

    -Mike
    Michael Geary, Aug 23, 2003
    #4
  5. Change of plans. The hooks library is at
    http://www.sourceforge.net/projects/uncassist. You can download and
    run the pyHook windows installer, or check it out of CVS. There's an
    example.py file in the CVS pyHook module that shows you how to use it
    (requires wxPython for the GUI).

    Pete

    (Peter Parente) wrote in message news:<>...
    > I have a Python library that can capture system wide keystrokes and
    > mouse events. Basically, the windows hooking code is in a C Python
    > extension that passes callback information back to Python when an
    > event occurs. I'll
    > post it to our Python tools sourceforge site in the near future. (I
    > need to clean it up a bit and provide an example before it will be the
    > least bit useful to you.)
    >
    > When it's posted, it will appear at
    > http://sourceforge.net/projects/uncpythontools/ as the pyHook project.
    >
    > Pete
    >
    >
    > hokieghal99 <> wrote in message news:<bi66lq$skj$>...
    > > Does anyone know of a keystroke logger that has been written in Python
    > > for Windows machines? I'd like to see such a script and use it as a
    > > point of reference for a real-time backup project that I'm working on.
    > > Basically, I'd like to be able to capture all keystrokes from the
    > > keyboard buffer and write them to a text file so I could reporduce
    > > emails, documents, etc. in the event of file loss that occurs between
    > > nightly backups. For example, my boss comes to me, he has deleted an
    > > email that he was writing... he has been working on the email all day...
    > > and he expects me to wave a magic wand and bring it back.
    > >
    > > Thanks for any advice, code or pointers. Also, if Python isn't suited
    > > for this, let me know and I'll look at doing this in c
    Peter Parente, Aug 25, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JustJohn
    Replies:
    6
    Views:
    625
    JustJohn
    Mar 29, 2006
  2. sachin
    Replies:
    1
    Views:
    944
    Soren Kuula
    Feb 3, 2006
  3. cap
    Replies:
    3
    Views:
    272
    James Edward Gray II
    Dec 11, 2005
  4. Georges Ko
    Replies:
    4
    Views:
    259
    Georges Ko
    Jul 26, 2006
  5. Derek Haskin

    keystroke logger

    Derek Haskin, Jul 30, 2006, in forum: Ruby
    Replies:
    0
    Views:
    136
    Derek Haskin
    Jul 30, 2006
Loading...

Share This Page