1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| import pyautogui as pag from time import sleep,time from color import * from os import system __all__ = ["__init__","mouse","key","api",'key_all'] key_all = ['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace', 'browserback', 'browserfavorites', 'browserforward', 'browserhome', 'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear', 'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete', 'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20', 'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja', 'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail', 'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack', 'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6', 'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn', 'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn', 'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator', 'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab', 'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen', 'command', 'option', 'optionleft', 'optionright'] class api: def __init__(self): print('\nroyi开发',FOREGROUND_SKYBLUE) def mouse(self,frequency:int,key:int,w_time:float): "连点鼠标 frequency:次数(int) key:左键请输入0,右键输入1(int) w_time:等待时间(float)" pag.PAUSE = 0 frequency=int(frequency) key=int(key) w_time=float(w_time) print('\n请注意:您需要在8秒内将鼠标移动到您需要连点的地方,然后不要动,等待开始快速连点。',FOREGROUND_YELLOW) sleep(8) print('开始点击!',FOREGROUND_YELLOW) x,y = pag.position() d = 'left' if key: d = 'right' e = time() for i in range(0,frequency): pag.click(x,y,button = d) sleep(w_time) f = time() - e print('完成。用时%f秒。' % f,FOREGROUND_SKYBLUE) system('pause') def key(self,frequency:int,key:str,w_time:float): "连按按键 frequency:次数(int) key:按键名称(str)" pag.PAUSE = 0 frequency=int(frequency) key=str(key) w_time=float(w_time) if key in key_all: print('\n请注意,您需要在8秒内切换到需要输入的窗口。',FOREGROUND_YELLOW) sleep(8) print('开始工作!',FOREGROUND_YELLOW) e = time() for i in range(0,frequency): pag.press(key) sleep(w_time) f = time() - e print('完成。用时%f秒。' % f,FOREGROUND_SKYBLUE) else: print('没有这个键.查询key_all列表了解支持按键.',FOREGROUND_RED) system('pause')
|