国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python實現模擬按鍵,自動翻頁看u17漫畫

2019-11-25 17:55:58
字體:
來源:轉載
供稿:網友

python
適用于windows平臺
使用 win32gui,win32api,win32con 包

simu_read.py

復制代碼 代碼如下:

#-*- coding=utf-8 -*-
'''
模擬按鍵翻頁
Usage:python simu_read.py 10 1.5
10表示翻10頁,1.5表示在一頁中按pgdn的時間間隔為1.5s
一頁pgdn 3 次,之后按→翻到下一頁
把瀏覽器打開到u17要看的漫畫中,之后啟動該程序,再切回u17
便可以自動翻頁看漫畫了。
僅供娛樂,了解python模擬按鍵
'''
import win32gui,win32api,win32con
from ctypes import *
import time
import threading
import sys
''' # mouse click is not used here ,-> can replace it
def get_cursor_pos():
    x,y = win32gui.GetCursorPos()
    return (x,y)
def mouse_move(x,y):
    windll.user32.SetCursorPos(x, y)
def mouse_click(x=None,y=None):
    print 'mouse_click'
    if not x is None and not y is None:
        mouse_move(x,y)
        time.sleep(0.05)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        time.sleep(0.05)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def test_pos():
    for i in range(0,10):
        time.sleep(0.5)
        print get_cursor_pos()
'''
def key_up(key_num):
    win32api.keybd_event(key_num,0,0,0)
    win32api.keybd_event(key_num,0,win32con.KEYEVENTF_KEYUP,0)
def init_dict():
    dict1 = {"PageDown":34,'RightArrow':39}
    return dict1
if __name__ == '__main__':
    if len(sys.argv) != 3:
        print 'Usage:python simu_read.py <pagenum> <interval>'
        sys.exit(-1)
    try:
        pagenum = int(sys.argv[1])
        interval = float(sys.argv[2])
    except ValueError:
        print 'Usage:python simu_read.py <pagenum> <interval>'
        print '<pagenum> should be the type of int'
        print '<interval> should be the type of float'
        sys.exit(-1)
    if pagenum < 0 or pagenum > 10000:
        print 'pagenum should be in the range [1,10000]'
        sys.exit(-1)
    if interval < 0.1 or interval > 60:
        print 'interval should be in the range [0.1,60]'
        sys.exit(-1)
    key_dict = init_dict()
    stsec = 2
    print 'start in '+str(stsec)+' seconds...'
    time.sleep(stsec)
    for i in range(0,pagenum):
        for j in range(0,3):#generally,the height of one page is not more than 3 screensize
            print 'PageDown'
            key_up(key_dict['PageDown'])
            time.sleep(interval)
        key_up(key_dict['RightArrow'])
        print 'Next page'
        time.sleep(interval+0.2)#delay
  

以上就是本文分享的全部內容了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 左贡县| 道孚县| 民权县| 瑞安市| 德化县| 德阳市| 平潭县| 张家川| 衢州市| 贵阳市| 筠连县| 六枝特区| 荥经县| 钟山县| 浮梁县| 云龙县| 酒泉市| 清远市| 樟树市| 淳安县| 三穗县| 林口县| 雅江县| 大渡口区| 临城县| 商都县| 吴桥县| 盱眙县| 苏尼特右旗| 南京市| 民乐县| 枞阳县| 双城市| 大名县| 苗栗市| 德兴市| 云和县| 友谊县| 宁晋县| 拉萨市| 油尖旺区|