import pyautogui import keyboard import time while True: time.sleep(0.1) while True: if keyboard.is_pressed('Num 1'): pyautogui.write('hello world!') break if keyboard.is_pressed('Num 2'): pyautogui.write('hello world!') break if keyboard.is_pressed('Num 3'): pyautogui.write('hello world!') break if keyboard.is_pressed('Num 4'): pyautogui.write('hello world!') break if keyboard.is_pressed('Num 5..