From 71197f5334a2bfbdd4decd4bc1c1b70a1a551cda Mon Sep 17 00:00:00 2001 From: LuNeder Date: Sat, 20 Feb 2021 16:04:03 -0300 Subject: [PATCH 1/4] Update alice.py --- alice.py | 71 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/alice.py b/alice.py index df9b54e..15e848d 100644 --- a/alice.py +++ b/alice.py @@ -25,30 +25,51 @@ import keyboard import time +import sys + +args = str(sys.argv) #Asks how many seconds between lines and saves answer as t -t = int(input("How many seconds between lines? -> ")) -print(t) - -#open file -original = open("original.txt", "r", encoding='utf-8') -conteudo = original.read() - -#divide file lines as list elements and print them -conteudo_lista = conteudo.splitlines() -original.close -print(conteudo_lista) - -#count how many elements are in the list and print the quantity -linhas = len(conteudo_lista) -print(linhas) - -#waits 10 seconds so you can find the text input area once Alice is running -time.sleep(10) - -#types each line and press0 enter, then waits t seconds before doing it with the next line -for i in range(linhas): - keyboard.write(conteudo_lista[i]), - time.sleep(0.5), - keyboard.press_and_release("enter"), - time.sleep(t) +if (args.__contains__("--help")): + mode = "help" + print("--help: Help mode: show this message") + print("--loop: Loop mode: start the file again from beginning after it's over") + print("no args: Normal mode: stop once file ends") +else: + t = int(input("How many seconds between lines? -> ")) + print(t) + + #open file + original = open("original.txt", "r", encoding='utf-8') + conteudo = original.read() + + #divide file lines as list elements and print them + conteudo_lista = conteudo.splitlines() + original.close + print(conteudo_lista) + + #count how many elements are in the list and print the quantity + linhas = len(conteudo_lista) + print(linhas) + + #waits 10 seconds so you can find the text input area once Alice is running + time.sleep(10) + +#types each line and press enter, then waits t seconds before doing it with the next line +if (args.__contains__("--loop")): + mode = "loop" + while True: + for i in range(linhas): + keyboard.write(conteudo_lista[i]), + time.sleep(0.5), + keyboard.press_and_release("enter"), + time.sleep(t) +elif (args.__contains__("--help")): + print("") +else: + mode = "normal" + for i in range(linhas): + keyboard.write(conteudo_lista[i]), + time.sleep(0.5), + keyboard.press_and_release("enter"), + time.sleep(t) From 0227d662e2c0e7a32ba6ac9eac0c56a753c43f81 Mon Sep 17 00:00:00 2001 From: LuNeder Date: Sat, 20 Feb 2021 16:12:27 -0300 Subject: [PATCH 2/4] Add loop mode (and comment code) Loop mode (run with --loop) restarts the file after it's over. Run with --help for more info Run without args to use the normal mode --- alice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alice.py b/alice.py index 15e848d..98659dc 100644 --- a/alice.py +++ b/alice.py @@ -27,15 +27,17 @@ import time import sys +#Save command line args as args args = str(sys.argv) -#Asks how many seconds between lines and saves answer as t +#Shows help if args contain --help, gets and prepare the file if args do not contain --help if (args.__contains__("--help")): mode = "help" print("--help: Help mode: show this message") print("--loop: Loop mode: start the file again from beginning after it's over") print("no args: Normal mode: stop once file ends") else: + #Asks how many seconds between lines and saves answer as t t = int(input("How many seconds between lines? -> ")) print(t) @@ -55,7 +57,7 @@ #waits 10 seconds so you can find the text input area once Alice is running time.sleep(10) -#types each line and press enter, then waits t seconds before doing it with the next line +#types each line and press enter, then waits t seconds before doing it with the next line. Keep doing this forever with a While Loop if args contain --loop. If args contain --help it'll just print an empty line if (args.__contains__("--loop")): mode = "loop" while True: From e77ebc92438ff27974654a8bb0cf407165b68ee2 Mon Sep 17 00:00:00 2001 From: LuNeder Date: Sat, 20 Feb 2021 16:20:57 -0300 Subject: [PATCH 3/4] Update alice.py --- alice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alice.py b/alice.py index 98659dc..08b5dfa 100644 --- a/alice.py +++ b/alice.py @@ -34,7 +34,7 @@ if (args.__contains__("--help")): mode = "help" print("--help: Help mode: show this message") - print("--loop: Loop mode: start the file again from beginning after it's over") + print("--loop: Loop mode: restart the file from beginning after it's over") print("no args: Normal mode: stop once file ends") else: #Asks how many seconds between lines and saves answer as t From 7d2e57d911cf783369d86b76efa20b72e2b987fa Mon Sep 17 00:00:00 2001 From: LuNeder Date: Sat, 20 Feb 2021 16:25:28 -0300 Subject: [PATCH 4/4] Update alice.py --- alice.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/alice.py b/alice.py index a4a6ebd..08b5dfa 100644 --- a/alice.py +++ b/alice.py @@ -34,9 +34,7 @@ if (args.__contains__("--help")): mode = "help" print("--help: Help mode: show this message") - print("--loop: Loop mode: restart the file from beginning after it's over") - print("no args: Normal mode: stop once file ends") else: #Asks how many seconds between lines and saves answer as t