建站学习网,专业提供各类建站教程,网页素材,SEO资讯等建站资源!

网站模板_网站源码_网站素材_建站教程_建站学习网

当前位置:建站学习网 > 网页设计 > 脚本HTML教程 >

python实现模拟按键,自动翻页看u17漫画

更新时间:2017-04-12整理编辑:建站学习网阅读:0

 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

 

以上就是本文分享的全部内容了,希望大家能够喜欢。

本文网址:https://www.dedexuexi.com/wysj/html/2847.html

本站部分文章搜集与网络,如有侵权请联系本站,转载请说明出处。

收藏此文 赞一下!() 打赏本站

如本文对您有帮助,就请建站学习网抽根烟吧!

支付宝打赏
微信打赏
HTML元素:isindex
« 上一篇2017年04月12日
XHTML+CSS布局之XHTML应用
2017年04月12日下一篇 »
  • 实现导航栏固定在顶部(吸顶效果),滚动页面万能方式
    0阅读
    1)滚动条不动时,是静态相对定位状态relative2)当页面滚动超出设置距离时,js改变样式属性切换定位状态变成fixed,同时再给top设置一个值css部分// 滚动条不动时.box{position: relative;height: 80px;width: 100%;z-index: 999...
  • HTML锚点用class样式教程
    0阅读
    JS部分:$(function() { $(window).scroll(function() { //为页面添加页面滚动监听事件 var wst = $(window).scrollTop() //滚动条距离顶端值 for (i = 1; i < 6...
  • python标准算法实现数组全排列的方法
    0阅读
    这篇文章主要介绍了python标准算法实现数组全排列的方法,实例分析了全排列的原理与Python实现技巧,需要的朋友可以参考下 本文实例讲述了python标准算法实现数组全排列的方法,代码来自国外网
  • python将ip地址转换成整数的方法
    0阅读
    这篇文章主要介绍了python将ip地址转换成整数的方法,涉及Python针对IP地址的转换技巧,需要的朋友可以参考下 本文实例讲述了python将ip地址转换成整数的方法。分享给大家供大家参考。具体分析如
  • 一个生成html的新方法
    0阅读
    使用范例: set fso=CreateObject(Scripting.FileSystemObject) set f=fso.CreateTextFile( server.mappath( ), true ) f.WriteLine( asp2html(youpage.asp) ) f.clos...
 
QQ在线咨询