diff --git a/GUI_script.py b/GUI_script.py index 7aa7eef..201fa1b 100644 --- a/GUI_script.py +++ b/GUI_script.py @@ -17,18 +17,20 @@ root_widget.title("KeyBoard Simulator") # Width and Height -root_widget.geometry('780x480') +root_widget.geometry("780x480") # Image frame = tk.Frame(root_widget, width=600, height=400) frame.pack() -frame.place(anchor='center', relx=0.5, rely=0.5) -body_image = ImageTk.PhotoImage(Image.open('gui_assets/type.jpg')) +frame.place(anchor="center", relx=0.5, rely=0.5) +body_image = ImageTk.PhotoImage(Image.open("gui_assets/type.jpg")) label_for_body_image = tk.Label(frame, image=body_image) label_for_body_image.pack() # Labeling the window title -root_window_title = tk.Label(root_widget, text="AutoType 🖊", fg="#8FBDD3", font=('', 62)) +root_window_title = tk.Label( + root_widget, text="AutoType 🖊", fg="#8FBDD3", font=("", 62) +) root_window_title.pack() # Input Box for Time Delay @@ -40,7 +42,9 @@ # Logic # Function for Addition of Time Delay def add_time_delay(): - mylable_time = tk.Label(root_widget, text=f"Time Delay of {entry_for_time_delay.get()} seconds added") + mylable_time = tk.Label( + root_widget, text=f"Time Delay of {entry_for_time_delay.get()} seconds added" + ) mylable_time.pack() @@ -58,13 +62,27 @@ def file_writer(): # Button widget instance -button_for_add_time_delay = tk.Button(root_widget, text="Add time Delay in Seconds", activebackground='#345', activeforeground='white', padx=5, - pady=5, command=add_time_delay) +button_for_add_time_delay = tk.Button( + root_widget, + text="Add time Delay in Seconds", + activebackground="#345", + activeforeground="white", + padx=5, + pady=5, + command=add_time_delay, +) button_for_add_time_delay.pack() # Button widget instance -button_for_writing_file = tk.Button(root_widget, text="Write File", activebackground='#345', activeforeground='white', padx=5, pady=5, - command=file_writer) +button_for_writing_file = tk.Button( + root_widget, + text="Write File", + activebackground="#345", + activeforeground="white", + padx=5, + pady=5, + command=file_writer, +) button_for_writing_file.pack() root_widget.mainloop() diff --git a/Simulator/__init__.py b/Simulator/__init__.py index 1e49c1f..5751159 100644 --- a/Simulator/__init__.py +++ b/Simulator/__init__.py @@ -1 +1 @@ -from .simulate_keyboard import Type \ No newline at end of file +from .simulate_keyboard import Type diff --git a/Simulator/simulate_keyboard.py b/Simulator/simulate_keyboard.py index d6df34c..6cf32ae 100644 --- a/Simulator/simulate_keyboard.py +++ b/Simulator/simulate_keyboard.py @@ -21,13 +21,13 @@ def __init__(self, x, y): self.y = y """ if path: - with open(path, 'r') as file: + with open(path, "r") as file: code = file.read() keyboard = Controller() - for line in code.split('\n'): + for line in code.split("\n"): keyboard.type(line) # It was observed that a small sleep in between each lines, makes Autotype perform better sleep(0.1) keyboard.tap(Key.enter) - keyboard.tap(Key.home) \ No newline at end of file + keyboard.tap(Key.home) diff --git a/command_line_script.py b/command_line_script.py index 8ca66a4..d73e153 100755 --- a/command_line_script.py +++ b/command_line_script.py @@ -5,16 +5,24 @@ from Simulator import Type import time + def autotype_cli( - path: Optional[str] = typer.Option(default="", - help=typer.style("the path to the file 🗂", fg=typer.colors.MAGENTA), - prompt=True, confirmation_prompt=True, show_default="Empty File Path"), - delay: Optional[int] = typer.Option(default=3, - help=typer.style( - "time ⌛️ delay before typing (in seconds)", - fg=typer.colors.MAGENTA), - show_default=3, - prompt=True)): + path: Optional[str] = typer.Option( + default="", + help=typer.style("the path to the file 🗂", fg=typer.colors.MAGENTA), + prompt=True, + confirmation_prompt=True, + show_default="Empty File Path", + ), + delay: Optional[int] = typer.Option( + default=3, + help=typer.style( + "time ⌛️ delay before typing (in seconds)", fg=typer.colors.MAGENTA + ), + show_default=3, + prompt=True, + ), +): """ A quick and small python script that helps you autotype on websites that have copy paste disabled like Moodle, HackerEarth contests etc as it is difficult to efficiently debug your code on an online compiler. @@ -25,22 +33,37 @@ def autotype_cli( return: Prints the File Given. """ if path and not os.path.isfile(path): - file_path = typer.style(f"{path}", fg=typer.colors.BRIGHT_WHITE, bg=typer.colors.BRIGHT_RED, bold=True) - error_message = typer.style("is not found Please Specify the correct Path.", fg=typer.colors.RED) + file_path = typer.style( + f"{path}", + fg=typer.colors.BRIGHT_WHITE, + bg=typer.colors.BRIGHT_RED, + bold=True, + ) + error_message = typer.style( + "is not found Please Specify the correct Path.", fg=typer.colors.RED + ) typer.echo(f"{file_path + ' ' + error_message} ") raise typer.Exit(code=0) else: total = 0 - with typer.progressbar(range(100), label=typer.style("Writing File in Progress -> ", fg=typer.colors.GREEN, - bold=True)) as progress: + with typer.progressbar( + range(100), + label=typer.style( + "Writing File in Progress -> ", fg=typer.colors.GREEN, bold=True + ), + ) as progress: for value in progress: time.sleep(0.01) total += 1 Type(path, delay) - successfull_file_path = typer.style(f"{path} File", fg=typer.colors.BRIGHT_GREEN) - time_taken = typer.style(f"is written in {abs(delay)} seconds", fg=typer.colors.BRIGHT_WHITE) + successfull_file_path = typer.style( + f"{path} File", fg=typer.colors.BRIGHT_GREEN + ) + time_taken = typer.style( + f"is written in {abs(delay)} seconds", fg=typer.colors.BRIGHT_WHITE + ) typer.echo(f"{successfull_file_path + ' ' + time_taken}") -if __name__ == '__main__': +if __name__ == "__main__": typer.run(autotype_cli)