Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # full code in answer to:
- # https://stackoverflow.com/questions/65801957/python-block-keyboard-mouse-input/65828426#65828426
- #### Blocking Keyboard ####
- import keyboard
- #blocks all keys of keyboard
- for i in range(150):
- keyboard.block_key(i)
- #### Blocking Mouse-movement ####
- import threading
- import mouse
- import time
- global executing
- executing = True
- def move_mouse():
- #until executing is False, move mouse to (1,0)
- global executing
- while executing:
- mouse.move(1,0, absolute=True, duration=0)
- def stop_infinite_mouse_control():
- #stops infinite control of mouse after 10 seconds if program fails to execute
- global executing
- time.sleep(10)
- executing = False
- threading.Thread(target=move_mouse).start()
- threading.Thread(target=stop_infinite_mouse_control).start()
- #### opening the video ####
- import subprocess
- import pyautogui
- import time
- subprocess.Popen(["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",])
- time.sleep(3)
- pyautogui.write('www.youtube.com/watch?v=DLzxrzFCyOs', interval= 0.1)
- pyautogui.hotkey('enter')
- #### stops moving mouse to (1,0) after video has been opened
- executing = False
Add Comment
Please, Sign In to add comment