-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypewriter.py
85 lines (77 loc) · 2.7 KB
/
typewriter.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
81
82
83
84
85
import sys
import keyboard as ky
import os
import pandas as pd
import time
from pynput.keyboard import Key,Controller
from threading import Thread
from os import path
from packages.break_key import break_key
from packages.list_win import switcher
from packages.winmsg import balloon_tip
#-----------------------------
keywords_import = "assets/google_trend_keywords.csv"
limit_words = 5
exit_key = "esc"
delay = 0 #in seconds
#----------------------------
br_key = Key.enter
aborted = False
counter = 0
def trigger():
global aborted
while not aborted:
if ky.is_pressed(exit_key):
aborted = True
break
def writer():
global counter,br_key, limit_words
if path.isfile(keywords_import) == False:
print("Can't find file, Please provide a clear way.")
os._exit(0)
else:
df = pd.read_csv(keywords_import)
list_of_key = df.values.tolist()
if len(list_of_key) < 1:
print("File don't have any content for writing.")
quit
os._exit(0)
else:
print("Found data for writing.")
#break key
br_key = break_key()
print("-----------------\n")
#keywords count
try:
limit_words = int(input("Keywords limit [Default is "+str(limit_words)+",'0' means unlimited]: "))
except:
print("Provide a numeric numbers of keywords.")
# switching window
switcher()
balloon_tip("Select Window","Please select any window for auto typing before it start typing.",5,False)
print("-----------------\n")
#Exit key
print("\n************\nExit key: ",exit_key,"\n************")
# starting count down
balloon_tip("Final Warning","Please confirm window for typing, otherwise u'll face some trouble.",8,True)
# starting typing
kc = Controller()
for i in list_of_key:
if aborted or counter > limit_words:
if limit_words != 0:
break
kc.type(i[0])
kc.press(br_key)
counter += 1
if delay > 0:
time.sleep(delay)
if aborted:
print("Process interrupted.")
elif counter > limit_words:
print("Limit reached. Update limit for more keywords.")
print(counter," keywords written.")
if __name__ == "__main__":
t1 = Thread(target = writer,args=())
t2 = Thread(target = trigger,args=())
t1.start()
t2.start()