def main(): do_the_application_login() currentdate = library.get_text(CURRENT_DATE) currenttime = library.get_text(CURRENT_TIME) LOGGER.info(f"CURRENT DATE: {currentdate['children_texts']}") LOGGER.info(f"CURRENT TIME: {currenttime['children_texts']}") click_transactions() click_configurations() type_cash(500, 300, 100) click_settings() set_slider_value("id:uiScaleSlider and type:Slider", 0.2) sleep(5) winlist = library.get_window_list() for w in winlist: LOGGER.info(w) library.refresh_window() set_slider_value("id:uiScaleSlider and type:Slider", 0.5) sleep(5) LOGGER.info("Done.") if __name__ == "__main__": library = Windows() try: main() finally: library.close_all_applications()
from RPA.Desktop.Windows import Windows win = Windows() def open_calculator(): win.open_from_search("calc.exe", "计算器") elements = win.get_window_elements() def make_calculations(expression): win.send_keys(expression) result = win.get_element_rich_text('id:CalculatorResults') return int(result.strip('显示为')) if __name__ == "__main__": open_calculator() exp = '5*2=' result = make_calculations(exp) print(f"Calculation result of '{exp}' is '{result}'") win.close_all_applications()
def minimize_maximize(windowtitle): library.minimize_dialog() sleep(1) library.restore_dialog() sleep(1) library.minimize_dialog() sleep(1) library.restore_dialog(windowtitle) def open_text_file(): filepath = Path(__file__).parent / "mytextfile.txt" library.open_file(filepath.absolute(), "Notepad", wildcard=True) element = library.get_element("class:Edit") assert element["legacy"]["Value"] == "Story of the Windows RPA" if __name__ == "__main__": library = Windows() try: open_text_file() open_calculator() minimize_maximize("Calculator") open_navigation("Standard Calculator") library.mouse_click("Clear") sleep(3) finally: library.close_all_applications()
from RPA.Desktop.Windows import Windows import time win = Windows() def open_calculator(): win.open_from_search("calc.exe", "Calculator") elements = win.get_window_elements() for j in range(len(elements[0])): #print(elements[0][j]) #print('los valores son :') #print(elements[1][j]['automation_id']) if elements[1][j]['automation_id'] == 'CalculatorResults': print(elements[1][j]) def make_calculations(expression): win.send_keys(expression) boton_conect = win.get_element_rectangle('id:CalculatorResults') print(boton_conect) result = win.get_element_rich_text('id:CalculatorResults') #print(result) return int(result.strip('Display is ')) def open_teamviewer(): #win.open_application("TeamViewer") win.open_from_search("TeamViewer", "TeamViewer") ##time.sleep(120) elements = win.get_window_elements()
import time from RPA.Desktop.Windows import Windows import os mode = "IMPORT" if mode == "EXPORT": #export win = Windows() win.open_executable("C:/HoMM3/h3maped.exe", "Map Editor", wildcard=True) for dirpath, dirs, files in os.walk("C:/original_maps"): for f in files: fn = os.path.join(dirpath, f).replace("/", "\\") if f.lower().endswith(".h3m") and not os.path.isfile( fn.replace(".h3m", ".txt")): hota = 0 if f.lower().startswith("[hota]"): hota = 1 if hota == 0: while True: try: win.menu_select("File->Open...") break except: time.sleep(2) win.send_keys("%s") win.send_keys("%n") time.sleep(1) win.send_keys_to_input(
# --- LIBS --- from RPA.Desktop.Windows import Windows win = Windows() # --- TASKS --- win.open_from_search("firefox", "Mozilla Firefox") win.send_keys_to_input("https://www.google.com") win.send_keys_to_input("RPA{SPACE}is{SPACE}cool") win.screenshot("desktop.png", desktop=True, overwrite=True) #win.close_all_applications print("Done!")