快速阅读强制翻页工具(备份)

2022年7月14日22:59:43 发表评论 1,150 views

19-20年开发的,对阅读速度提升挺大的,也便于快速提高认知水平,版本太多就把这个能用的备份出来。

 

import pyautogui as at
import keyboard
import time
from threading import Thread,Lock
#  带有enter翻页和1秒内不翻页功能
lock = Lock()
over_time_is = int(input('请输入自动翻页时间:'))

over_time = over_time_is   # 设置翻页时间
stay_time = 0.8   # 剩余时间低于这个数不翻页(防止手动翻页后再自动翻页)


def next_page():
    """
    自动翻页:按时间点击下一页   当小于设定时间后按下pagedown
    :return:
    """
    global over_time
    while True:
        try:
            if over_time>0:
                time.sleep(0.1)
                lock.acquire()
                over_time -=0.1
                lock.release()
            else:
                at.press('pagedown')
                over_time = over_time_is    # 翻页并设置时间为输入的时间,然后循环重新计时
        except:
            pass



def clean_time():
    """
    # 手动按下翻页后调用此方法清除计时时间并重新计时。
    :return:
    """
    lock.acquire()
    global over_time
    over_time = over_time_is
    lock.release()
    print('时间重置')


def clear_time():
    """
    监测到手动按下space或者pagedown翻页后,重置自动翻页时间
    监测到按下enter后,调用pagedown翻页函数实现手动翻页(用于早期阅读器版本不支持回车翻页)
    :return:
    """
    global over_time
    while True:
        keyboard.add_hotkey('space',clean_time)
        keyboard.add_hotkey('pagedown',clean_time)
        keyboard.add_hotkey('enter',enter_page_down)
        #注释掉暂停功能
        # keyboard.add_hotkey('-',pause,args=(1,))
        # keyboard.add_hotkey('+',pause,args=(0,))
        break


def enter_page_down():
    """
    检查如果声誉时间大于翻页时间则pagedown,用于防止到时间的瞬间按下翻页键造成两次翻页
    :return:
    """
    global over_time
    try:
        if over_time > stay_time:
            at.press('pagedown')
            over_time = over_time_is
            time.sleep(0.3)
        else:
            pass

    except:
        pass
    


# 监听翻页按键   #暂时删除,加入上面cleartime
# def listen_double_click():
#     while True:
#         keyboard.add_hotkey('enter',enter_page_down)
#         break
#使用+-号暂停
def pause(sign):
    global over_time
    if sign == 1:  # 暂停
        over_time += 1000000
        print('已暂停')
    if sign == 0:
        over_time -=3000000
        print('继续')
    


# 监听翻页指令鼠标位置(用轨迹球时贼好用)
def mouse_pagedown():
    while True:
        try:
            position = at.position()  # 设置鼠标触发坐标  左上角是0,0
            if position[0]< 50:   #修改这个打开关闭鼠标触摸翻页功能  默认100
                enter_page_down() # 如果大于stay时间则翻页并重置时间
                time.sleep(0.1)# 0.3该0.1 加快连续翻页
                position = at.position()
                if position[0]>130:  
                    pass
                else:
                    # at.moveTo(120,850)
                    at.moveTo(120,position[1])
                print(position)
        except Exception as e:
            print(e)

t1 = Thread(target = next_page)   #时间自动翻页功能

t11 = Thread(target = clear_time)  # 监测键盘并调用翻页功能

#暂时注释鼠标移动翻页
t13 = Thread(target = mouse_pagedown)

t1.start() 
t11.start()
t13.start()


t1.join()
t11.join()
t13.join()

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: