I am trying to enter Alt-codes of symbols using the pynput library (Imitation of pressing "Alt" and entering code on the numpad)
from pynput.keyboard import Key, Controller
keyb = Controller()
def alt_codes(start, finish):
for i in range(start, finish + 1):
keyb.press(Key.alt)
time.sleep(0.01)
for j in str(i):
keyb.press(j)
time.sleep(0.01)
keyb.release(j)
time.sleep(0.01)
keyb.release(Key.alt)
time.sleep(0.01)
keyb.press(Key.space)
time.sleep(0.01)
keyb.release(Key.space)
But if I just try to simulate pressing the numbers 0 to 9, it doesn't work, because it simulates pressing the keys that are above the letters, and to enter the Alt code, you need to simulate the numbers from the Numpad. How can I simulate pressing numbers on a numpad? UPD: You can use any other library if needed.
from Entering numbers from the numpad using pynput (or any other library)
No comments:
Post a Comment