我正在尝试创建一个使用用户输入的自动打字机。对于第一行,自动打字机按预期工作,但在第二行,出现错误。我想知道是不是因为我做的例外?
这是我的完整代码:
import time
import random
from goto import with_goto
keyboard = Controller()
class label(Exception): pass
print('======Welcome to Autotyper v0.5 Currently still in development. We have a maximum of 4 lines, for bugs/suggestions email: alexanderhan00@gmail.com======')
while True:
line1 = input("Please enter your first line: ")
line2 = input("Please enter your second line, type none if you don't have one: ")
if line2 == "none":
break
line3 = input("Please enter your third line, type none if you don't have one: ")
if line3 == "none":
break
line4 = input("Please enter your fourth line, This is the last line!! ")
break
hours = input("How many hours would you like to run this? ")
retry = input("How long will it take until new message?(Seconds) ")
timeout = round(time.time())
future = round(time.time()) + int(60)*int(60)*int(hours)
x = 5
print('Move cursor to target')
while x > 0:
print(int(x)*'.')
time.sleep(1)
x = x-1
runs = 0
while True:
random.seed()
random1 = random.randint(0,10)
for char in line1:
keyboard.press(char)
keyboard.release(char)
time.sleep(0.1)
keyboard.press(Key.shift)
keyboard.press(Key.enter)
keyboard.release(Key.shift)
keyboard.release(Key.enter)
try:
line2 = 1
except NameError:
break
else:
for char in line2:
keyboard.press(char)
keyboard.release(char)
time.sleep(0.1)
keyboard.press(Key.shift)
keyboard.press(Key.enter)
keyboard.release(Key.shift)
keyboard.release(Key.enter)
runs = runs + 1
if timeout > future or runs == hours*60:
break
print("Random Seconds Added:")
print(int(random1))
print("Time to next entry:")
for y in range(int(retry) + int(random1)):
print(int(retry) + int(random1 - y))
time.sleep(1)
非常感谢任何帮助,谢谢!我是社区的新手。
森栏
相关分类