By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Keystroke logger for Windows

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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" <ho********@hotmail.com> wrote in message
news:bi**********@solaris.cc.vt.edu...
| 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
|
Jul 18 '05 #2

P: n/a
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" <ho********@hotmail.com> wrote in message
news:bi**********@solaris.cc.vt.edu...
| 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
|
Jul 18 '05 #3

P: n/a
> 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
Jul 18 '05 #4

P: n/a
> 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
Jul 18 '05 #5

P: n/a
> 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
Jul 18 '05 #6

P: n/a
> 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
Jul 18 '05 #7

P: n/a
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

pa*****@cs.unc.edu (Peter Parente) wrote in message news:<85**************************@posting.google. com>...
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 <ho********@hotmail.com> wrote in message news:<bi**********@solaris.cc.vt.edu>...
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

Jul 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.