-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetClipboardData.py
More file actions
28 lines (20 loc) · 1011 Bytes
/
getClipboardData.py
File metadata and controls
28 lines (20 loc) · 1011 Bytes
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
# --------------------------------------------------------------------------------------------------------
# IMPORTING LIBRARIES
# Import ClipBoard Acess libraries
import os
import win32clipboard
# --------------------------------------------------------------------------------------------------------
def copy_clipboard():
# Check if the file exists, create if it doesn't
file_exists = os.path.exists("clipboard.txt")
with open("clipboard.txt", "a") as f:
if not file_exists:
f.write("Clipboard log initiated.\n")
try:
win32clipboard.OpenClipboard()
pasted_data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
f.write("\n\nClipBoard Data:\n" + pasted_data)
except Exception as e:
f.write("\n\nCouldn't copy clipboard data: " + str(e))
# copy_clipboard()