-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpasta.py
More file actions
executable file
·80 lines (67 loc) · 1.96 KB
/
pasta.py
File metadata and controls
executable file
·80 lines (67 loc) · 1.96 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
#!/usr/bin/env python3
# Pasta - One Way Super-Paste
#
# Author: Wes Moskal-Fitzpatrick
#
# Created to get around frustration of working with remote desktop
# configurations (usually Citrix) where copy and paste is disabled.
#
# Pasta uses pyautogui and keyboard to re-type text stored in the
# clipboard as you would with your human digits, only thousands of
# times faster.
#
# Change History
# --------------
# 2020-09-22 : 0.1 : WMF : Created.
# 2020-09-24 : 0.2 : WMF : Removed commented out test code.
#
import argparse
import tkinter
import time
import pyautogui
import keyboard
def main(countdown):
def countDown():
"""start countdown seconds"""
for k in range(countdown, -1, -1):
clock["text"] = k
time.sleep(1)
root.update() # Tk needs this after sleep()
clock["text"] = "Done"
root = tkinter.Tk()
root.geometry("200x100")
root.title('Pasta')
root.attributes("-topmost", True)
def submitFunction():
button.place_forget()
countDown()
# Click into window
x, y = pyautogui.position()
pyautogui.click(x, y)
# "Paste"
keyboard.write(clipboard)
ready.set(1)
clipboard = root.clipboard_get()
clock = tkinter.Label()
clock.place(relx=.5, rely=.7, anchor="c")
ready = tkinter.IntVar()
info = tkinter.Label(
text="Click 'Ready' and select the window to paste to...",
wraplength=150,
justify="left",
)
info.place(relx=.1, rely=.1)
button = tkinter.Button(root, text="Ready", command=submitFunction)
button.place(relx=.5, rely=.7, anchor="c")
root.wait_variable(ready)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Re-type clipboard text")
parser.add_argument(
"-t",
"--timer",
type=int,
default=3,
help="Countdown in seconds before typing begins",
)
args = parser.parse_args()
main(args.timer)