def run(): window = bring_bdo_top(refresh_wins()) print(window) some_var = autoit.win_active(window) print(some_var) some_var_2 = autoit.win_activate(window) print(some_var_2) some_var = autoit.win_active(window) print(some_var) some_var = autoit.win_get_handle(window) time.sleep(2) autoit.control_send(window, "", "r")
def find_native_window(self, window_name, timeout=5): """ Wait for a native window to become visible Example: | Wait for Native Window | Calculator | """ logger.debug("Waiting {0}s for native window '{1}'".format( timeout, window_name)) try: autoit.win_wait(window_name, timeout) except autoit.AutoItError: logger.warn("Can't find native window!") return None hwnd = autoit.win_get_handle(window_name) logger.debug("Found native window '{0}'. Handle is {1}".format( window_name, hwnd)) return hwnd
def add_photo(image_path): """ Метод добавляет фото по указанному пути :param image_path: - абсолютный путь до фото :return: """ import autoit title = "[CLASS:#32770]" control = '[CLASS:Edit; INSTANCE:1]' control_open_btn = '[CLASS:Button; INSTANCE:1]' opened = autoit.win_wait(title, 5) if opened != 1: msg = "Not opened window!" service_log.error(msg) assert msg handle = autoit.win_get_handle(title) if isinstance(handle, int) is not True: msg = "Not found Handle!" service_log.error(msg) assert msg autoit.win_activate_by_handle(handle) ret = autoit.control_focus(title, control) if ret != 1: msg = "Not found control_focus!" service_log.error(msg) assert msg time.sleep(1) autoit.control_set_text(title, control, image_path) autoit.control_focus(title, control_open_btn) autoit.control_click(title, control_open_btn) #autoit.mouse_click() #ENTER - подтверждение (можно вместо этого нажать на кнопку) #autoit.send("{ENTER}") time.sleep(5) return True
def get_current_native_window_focus(self): """ Return a handle of the foreground window Example: | Get Current Native Window Focus | """ return autoit.win_get_handle("")
import sys import autoit autoit.auto_it_set_option("WinTitleMatchMode", 2) autoit.auto_it_set_option("WinTextMatchMode", 1) appName = sys.argv[1].title() try: appHandle = autoit.win_get_handle(appName) autoit.win_close_by_handle(appHandle) except: print("Application could not be found.\n")
import autoit import time autoit.run("C:\\Users\\Tobias_Artur\\AppData\\Local\\Obsidian\\Obsidian") autoit.win_wait_active("Obsidian", 0) obsidian = autoit.win_get_handle("Obsidian") print(obsidian) autoit.win_move_by_handle(obsidian, 1273, 0, 1300, 1087) #time.sleep(3) #autoit.win_close_by_handle(obsidian) ############################################################################################### autoit.run("C:\\Program Files\\Mozilla Firefox\\firefox") autoit.win_wait_active("Mozilla Firefox", 0) firefox = autoit.win_get_handle("Mozilla Firefox") print(firefox) autoit.win_move_by_handle(firefox, -7, 0, 1287, 1087) #time.sleep(3) #autoit.win_close_by_handle(firefox) ############################################################################################### autoit.run("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome") #autoit.run('C:\\Program Files (x86)\\Chromium\\Application\\chrome') # With chromium, you can get away just typing in "Google" autoit.win_wait_active("ServiceNow - Google Chrome", 0) chrome = autoit.win_get_handle("ServiceNow - Google Chrome") print(chrome) autoit.win_move_by_handle(chrome, 2560, 0, 1280, 1080) #time.sleep(3)