Python
Applies to Windows platform
Using the Win32gui,win32api,win32con Package
simu_read.py
Copy Code code as follows:
#-*-Coding=utf-8-*-
'''
Analog Button Page
Usage:python simu_read.py 10 1.5
10 represents 10 pages, and 1.5 means the time interval of PgDn per page is 1.5s
One page PgDn 3 times, then press → turn to the next page
Open the browser to U17 to see the comics, then start the program, and then cut back to U17
You can automatically turn the page to read comics.
For entertainment only, learn about Python simulation keys
'''
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 are none and not Y are 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": ' 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 is in the range [1,10000] '
Sys.exit (-1)
If interval < 0.1 or interval > 60:
print ' interval should is 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 isn't 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
The above is the entire content that this article shares, hoped everybody can like.