<返回更多

python 定时器

2022-06-08    正义凛然神经蛙
加入收藏
import datetime
import threading
import time
import keyboard
import schedule


def block_keyboard():
    print("block...", datetime.datetime.now())
    for i in range(150):
        keyboard.block_key(i)
    threading.Timer(10, unblock_keyboard).start()


def unblock_keyboard():
    print("unblock...", datetime.datetime.now())
    for i in range(150):
        keyboard.unblock_key(i)
    threading.Timer(10, block_keyboard).start()


def job():
    block_keyboard()
    threading.Timer(10, unblock_keyboard).start()


if __name__ == '__main__':
    print("start...", datetime.datetime.now())
    block_keyboard()
    # schedule.every(10).seconds.do(job)
    # while True:
    #     schedule.run_pending()
声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>