473,414 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Keystroke logger for Windows

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
7 6209
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
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
> 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
> 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
> 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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nermin Brgulja | last post by:
Hi, I am using jdk1.4 Logger with a FileHandler for logging in a web application, and have two questions regarding logging: The first question is: I've created an Logger and mapped it to an...
0
by: Laszlo | last post by:
Hi I need a GL::Logger wich implements Class::Singleton to be a singleton and Log::Log4perl to can log amy message into a file. Here is the module source:...
2
by: beaker | last post by:
Hello, I'm writing a program (which will be running in the background 99% of the time) and I want to be able to work out how long it has been since the user last used the mouse and/or keyboard. ...
1
by: rodsatt | last post by:
Hi, This is my first post, and I got questions about logging. When something happen within an object, and if I would like to log the event, what would be a good way to do it? 1. I make the...
5
by: CedricCicada | last post by:
Greetings! I want to write messages into the Windows event log. I found sevicemanager, but the source is always "Python Service", and I'd like to be a bit more descriptive. Poking around on...
4
by: garyjefferson123 | last post by:
Suppose I have some sort of context variable that I want to appear in log messages. E.g.: logger = logging.getLogger("somelogger") class SomeOp: def __init__(self, ctx): self.ctx = ctx def...
1
by: nagk9 | last post by:
Hi , I am using log4j in my application. I have the problem with log4j.properties file . It will automatically appends another logger file from the current logger which i am using for the...
1
by: Matimus | last post by:
Yes but in the other hand :http://docs.python.org/library/logging.html#logger-objects That is part of the power of the logging module. If you ask for a logger of the same name in two different...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.