Iam是信息安全领域的新成员,我试图自学如何用python构建一个简单的键盘记录器,我在一个网站上发现了以下代码:import pythoncom, pyHook
def OnkeyboardEvent(event):
print 'MessageName:',event.MessageName
print 'Message:',event.Message
print 'Time:',event.Time
print 'Window:',event.Window
print 'WindowName:',event.WindowName
print 'Ascii:', event.Ascii, chr(event.Ascii)
print 'Key:', event.Key
print 'KeyID:', event.KeyID
print 'ScanCode:', event.ScanCode
print 'Extended:', event.Extended
print 'Injected:', event.Injected
print 'Alt', event.Alt
print 'Transition', event.Transition
print '---'
# return True to pass the event to other handlers
return True
# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
当我试图理解这段代码时,我发现函数“OnKeyboardEvent”的调用没有给出它的参数
^{pr2}$
所以我的问题是:
在python中有没有一种方法可以在不给函数参数的情况下调用它?在