-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtel-typewriter
More file actions
executable file
·71 lines (66 loc) · 2.66 KB
/
Copy pathtel-typewriter
File metadata and controls
executable file
·71 lines (66 loc) · 2.66 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
#!/usr/bin/env python
from time import sleep
import random
import sys
import os
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-k", "--keypress", default='', help="Simulate a Keypress or mouse event. Examples of possible values: Escape, Tab, DC, BSpace, Enter, Up, Down, Left, Right, C-c, M-a")
parser.add_argument("-i", "--input", default='', help="String to type out in humanized fashion")
parser.add_argument("-t", "--target", default='', help="tmux pane target, can be numbers or vars or positional, eg right, top-right, bottom etc")
args = parser.parse_args()
def randomdelay():
delaytime = random.uniform(0.02,0.4)
return delaytime
def humanize_with_typo(target_pane):
chance = int(random.uniform(0,10))
possible = "abcdefghijklmnopqrstuvxyz"
if chance == 1:
if target_pane:
os.system("tmux send-keys " + target_pane + ' ' + possible[int(random.uniform(0,24))])
sleep(randomdelay())
os.system("tmux send-keys " + target_pane + " " + "BSpace")
sleep(randomdelay())
else:
os.system("tmux send-keys " + possible[int(random.uniform(0,24))])
sleep(randomdelay())
os.system("tmux send-keys BSpace")
sleep(randomdelay())
def main():
if args.target:
target_pane = "-t " + args.target.strip()
else:
target_pane = ''
if args.input:
try:
character = 0
for character in range(0,len(args.input)):
if args.input[character] == ' ':
if target_pane:
os.system("tmux send-keys " + target_pane + ' ' + "Space")
else:
os.system("tmux send-keys " + "Space")
continue
sleep(randomdelay())
else:
humanize_with_typo(target_pane)
if target_pane:
os.system("tmux send-keys " + target_pane + ' ' + args.input[character])
else:
os.system("tmux send-keys " + args.input[character])
sleep(randomdelay())
if args.keypress:
if target_pane:
os.system("tmux send-keys " + target_pane + ' ' + args.keypress)
else:
os.system("tmux send-keys " + args.keypress)
except:
print('except')
else:
if target_pane:
os.system("tmux send-keys " + target_pane + ' ' + args.keypress)
else:
os.system("tmux send-keys " + args.keypress)
if __name__ == "__main__":
main()