from pynput import mouse,keyboard
import os,time
def xit():print('a'+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))),os.system('pause'),os._exit(0)
def handle_mouse_event(*args):xit()
def handle_keyboard_event(key):xit()
time.sleep(5)
print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
mouse_listener = mouse.Listener(on_move=handle_mouse_event,on_click=handle_mouse_event)
keyboard_listener = keyboard.Listener(on_press=handle_keyboard_event)
mouse_listener.start(),keyboard_listener.start()
mouse_listener.join(),keyboard_listener.join()
After running, it will detect whether the mouse and keyboard are moving after 5 seconds, including but not limited to buttons, movement, scroll wheel, RGB keys, etc.
After running for 5 seconds, it will output a time. This is your running time. If the mouse or keyboard moves, It will output another time starting with a, which is the triggered time
The advantage of this is that if someone accidentally touches it, but runs it again cleverly, the output running time can prevent others from making false impressions