python實(shí)現(xiàn)模擬按鍵,自動(dòng)翻頁看u17漫畫
更新時(shí)間:2015年03月17日 11:31:33 投稿:hebedich
這篇文章主要介紹了python實(shí)現(xiàn)模擬按鍵,自動(dòng)翻頁看u17漫畫,十分簡(jiǎn)單實(shí)用,需要的朋友可以參考下
python
適用于windows平臺(tái)
使用 win32gui,win32api,win32con 包
simu_read.py
復(fù)制代碼 代碼如下:
#-*- coding=utf-8 -*-
'''
模擬按鍵翻頁
Usage:python simu_read.py 10 1.5
10表示翻10頁,1.5表示在一頁中按pgdn的時(shí)間間隔為1.5s
一頁pgdn 3 次,之后按→翻到下一頁
把瀏覽器打開到u17要看的漫畫中,之后啟動(dòng)該程序,再切回u17
便可以自動(dòng)翻頁看漫畫了。
僅供娛樂,了解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
以上就是本文分享的全部?jī)?nèi)容了,希望大家能夠喜歡。
您可能感興趣的文章:
- Python 實(shí)現(xiàn)鍵盤鼠標(biāo)按鍵模擬
- Python實(shí)現(xiàn)windows下模擬按鍵和鼠標(biāo)點(diǎn)擊的方法
- python實(shí)現(xiàn)按鍵精靈找色點(diǎn)擊功能教程,使用pywin32和Pillow庫(kù)
- python中字典按鍵或鍵值排序的實(shí)現(xiàn)代碼
- python按鍵按住不放持續(xù)響應(yīng)的實(shí)例代碼
- python對(duì)綁定事件的鼠標(biāo)、按鍵的判斷實(shí)例
- Python中按鍵來獲取指定的值
- Python實(shí)現(xiàn)的字典排序操作示例【按鍵名key與鍵值value排序】
- Python實(shí)現(xiàn)對(duì)字典分別按鍵(key)和值(value)進(jìn)行排序的方法分析
- python 字典(dict)按鍵和值排序
- Python可跨平臺(tái)實(shí)現(xiàn)獲取按鍵的方法
- Python 隨機(jī)按鍵模擬2小時(shí)
相關(guān)文章
教你使用Python pypinyin庫(kù)實(shí)現(xiàn)漢字轉(zhuǎn)拼音
今天,發(fā)現(xiàn)了一個(gè)好玩兒的庫(kù),叫做 “pypinyin ”,用于幫助我們實(shí)現(xiàn)漢字轉(zhuǎn)拼音,文中有非常詳細(xì)的代碼示例,對(duì)正在學(xué)習(xí)python的小伙伴們很有幫助,需要的朋友可以參考下2021-05-05tensorflow實(shí)現(xiàn)softma識(shí)別MNIST
這篇文章主要為大家詳細(xì)介紹了tensorflow實(shí)現(xiàn)softma識(shí)別MNIST,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03Python 新建文件夾與復(fù)制文件夾內(nèi)所有內(nèi)容的方法
今天小編就為大家分享一篇Python 新建文件夾與復(fù)制文件夾內(nèi)所有內(nèi)容的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10用Python寫腳本自動(dòng)評(píng)論再也不怕碰到噴子
這篇文章主要介紹了如何用Python寫腳本哎實(shí)現(xiàn)網(wǎng)站上自動(dòng)評(píng)論,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08