Advertisement
ADevingFre

stupid

Aug 9th, 2022 (edited)
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. from time import sleep
  2. import keyboard
  3. import pyclip
  4.  
  5. D = {val: i for i, val in enumerate("abcdefghijklmnopqrstuvwxyz", start=1)}
  6. REVERSED_D = {i - 1: val for val, i in D.items()}
  7.  
  8.  
  9. def _decompose(number):
  10.     while number:
  11.         number, remainder = divmod(number - 1, 26)
  12.         yield remainder
  13.  
  14.  
  15. def to_base(number):
  16.     return ''.join(REVERSED_D[part] for part in _decompose(number))[::-1]
  17.  
  18.  
  19. def from_base(base26string):
  20.     return sum(D[val] * 26 ** i for i, val in enumerate(base26string[::-1]))
  21.  
  22.  
  23. COOLDOWN = .5
  24. while True:
  25.     keyboard.wait("ctrl+c")
  26.     sleep(COOLDOWN)  # im having issues with the trigger_on_release arg in keyboard.wait so im manually sleeping
  27.  
  28.     try:
  29.         inp = pyclip.paste().decode("ascii") # yes this will read everything you copy, problem?
  30.         current = from_base(inp) + 1 # r"[a-z]+" would be regex so i could move this out of try except but im lazy
  31.     except:     # handling eiter non text pyclip.paste or non-convertable inp to from_base function
  32.         continue
  33.        
  34.     for i in range(current, current + len(inp)):
  35.         keyboard.write(to_base(i))
  36.         keyboard.send("\n")
  37.         sleep(max(COOLDOWN / len(inp), .1))
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement