Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError (pyHook)
#1
So, im trying to make a Keylogger in python but i always get the same error. I have watched different youtube videos on how to make a keylogger, and i have tried some of the different methods. but i get this one error.

This is how im writing the keylogger:

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()
And here is the error im getting:
Error:
Traceback (most recent call last):   File "C:/Users/Henrik/Desktop/lal.pyw", line 13, in <module>     hooks_manager.HookKeyBoard() AttributeError: 'HookManager' object has no attribute 'HookKeyBoard'
Im pretty new to programming, so i dont know much about it. But i wanted to try and make a Keylogger as my first project.
Reply
#2
hooks_manager.HookKeyBoard()
Should be
hooks_manager.HookKeyboard()
Reply
#3
Writing:
import pyHook, pythoncom, os, httplib, urllib, getpass, shutil, sys
def OnKeyBordEvent(event):
    print event.Ascii
hook_manager = pyHook.HookManager ()
hook.manager.KeyDown = OnKeyBoardEvent
hook_manager.HookKeyboard()
pythoncom.PumpMessages()
Error:
Traceback (most recent call last):   File "C:/Users/Henrik/Desktop/KeyLogger.py", line 5, in <module>     hook.manager.KeyDown = OnKeyBoardEvent NameError: name 'OnKeyBoardEvent' is not defined
Thanks!
Reply
#4
Check your spelling.
>>> 'OnKeyBordEvent' == 'OnKeyBoardEvent'
False
Reply
#5
(Nov-12-2016, 11:08 PM)snippsat Wrote: Check your spelling.
>>> 'OnKeyBordEvent' == 'OnKeyBoardEvent'
False

import pyHook, pythoncom, os, httplib, urllib, getpass, shutil, sys
def OnKeyBoardEvent(event):
    print event.Ascii
hook_manager = pyHook.HookManager ()
hook.manager.KeyDown = OnKeyBoardEvent
hook_manager.HookKeyboard()
pythoncom.PumpMessages()
but i still get this error:
Traceback (most recent call last):
  File "C:/Users/Henrik/Desktop/KeyLogger.py", line 5, in <module>
    hook.manager.KeyDown = OnKeyBoardEvent
NameError: name 'hook' is not defined
Reply
#6
Use code tag.
Now is . that should be _
hook_manager.KeyDown = OnKeyBoardEvent
Reply
#7
hook.manager should be hook_manager
Reply
#8
(Nov-13-2016, 12:00 AM)snippsat Wrote: Use code tag.
Now is . that should be _
hook_manager.KeyDown = OnKeyBoardEvent

Thanks!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020