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
| from __future__ import print_function import pyautogui import win32con import win32gui import os from pynput.mouse import Button, Controller import ctypes, sys import time
g_adsl_account={ "name":"ZJGSU", "username":"2012190228", "password":"123456"} app_path=r"C:\Program Files (x86)\cmclient\bin\CMClient.exe"
class Adsl(object): def __init__(self,object): self.name=object["name"] self.username=object["username"] self.password=object["password"] def set_adsl(self, account): self.name=account["name"] self.username=account["username"] self.password=account["password"] def connect(self): cmd_str="rasdial %s %s %s"%(self.name,self.username,self.password) os.system(cmd_str) def disconnect(self): cmd_str="rasdial %s /disconnect"%self.name os.system(cmd_str) def reconnect(self): self.disconnect() self.connect() def open_app(app_dir): os.startfile(app_dir) def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if __name__ == '__main__': auto=Adsl(g_adsl_account) auto.connect() if is_admin(): open_app(app_dir=app_path) else: if sys.version_info[0] == 3: ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1) else: ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1) time.sleep(2) pyautogui.moveTo(1120, 508) pyautogui.click(clicks=1) FrameTitle="随e行" hwnd=win32gui.FindWindow(None, FrameTitle) win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
|