def select_value_from_dropdown_list(self, control_id, value_to_select): """ Example: Select Value From Dropdown List | [NAME:ccboClass_1] | Class Code Sample """ autoit.win_activate('Power Express') autoit.control_click('Power Express', control_id) autoit.send('{BACKSPACE}') autoit.send('{HOME}') while 1: item_combo_value = autoit.control_get_text('Power Express', control_id) if item_combo_value == value_to_select: autoit.control_focus('Power Express', control_id) autoit.send('{ENTER}') autoit.send('{TAB}') break else: autoit.control_focus('Power Express', control_id) autoit.send('{DOWN}') if autoit.control_get_text('Power Express', control_id) == item_combo_value: BuiltIn().fail("Dropdown '" + value_to_select + "' value is not found") break
def get_value_from_dropdown_list(self, control_id): """ Returns a list containing all values of the specified dropdown. The default dropdown value is retained. """ dropdown_list = [] autoit.win_activate('Power Express') autoit.control_focus('Power Express', control_id) original_value = autoit.control_get_text('Power Express', control_id) autoit.send('{BACKSPACE}') autoit.send('{HOME}') while 1: item_combo_value = autoit.control_get_text('Power Express', control_id) dropdown_list.append(item_combo_value) autoit.send('{DOWN}') if autoit.control_get_text('Power Express', control_id) == item_combo_value: break autoit.send('{BACKSPACE}') autoit.send('{HOME}') for item in dropdown_list: if original_value == autoit.control_get_text( 'Power Express', control_id): break else: autoit.send('{DOWN}') return dropdown_list
def _entrust_0(self, direction, code, price, volume): ret_code = -1 ret_value = tools.get_timestamp() error_msg = '' if direction == 'b': cid_code = self.cid_buy_code cid_price = self.cid_buy_price cid_volume = self.cid_buy_volume cid_able = self.cid_buy_able cid_entrust = self.cid_buy_entrust wait_flag = True elif direction == 's': cid_code = self.cid_sell_code cid_price = self.cid_sell_price cid_volume = self.cid_sell_volume cid_able = self.cid_sell_able cid_entrust = self.cid_sell_entrust wait_flag = False else: error_msg = 'unexpected direction' return (ret_code, ret_value, error_msg, self.local_log_path) ret_code = 1 try: autoit.win_activate(self.wid_main) self.clean_dlg() autoit.control_set_text(self.wid_main, cid_code, code) if wait_flag: for count in range(30): if autoit.control_get_text(self.wid_main, cid_able) != '': ret_code = 2 break else: time.sleep(0.1) if ret_code != 2: error_msg = 'code response timeout' return (ret_code, ret_value, error_msg, self.local_log_path) ret_code = 3 autoit.control_set_text(self.wid_main, cid_price, price) autoit.control_set_text(self.wid_main, cid_volume, volume) #autoit.win_activate(self.wid_main) autoit.control_click(self.wid_main, cid_entrust) ret_code = 4 if autoit.win_wait(self.wid_prompt, timeout=3) == 1: #autoit.win_activate(self.wid_prompt) autoit.control_click(self.wid_prompt, self.cid_prompt_ok) ret_code = 0 except autoit.AutoItError: error_msg = traceback.format_exc() return (ret_code, ret_value, error_msg, self.local_log_path)
def user_control_wait_text(title, control, text): while True: try: if text in autoit.control_get_text(title, control): break except: #ErrorHandle() continue
def CheckWindow(self): while True: try: message = autoit.control_get_text("[CLASS:#32770]", "[CLASS:msctls_statusbar32; INSTANCE:1]") if message == "Nothing found": autoit.win_close("On-Demand Scan Progress") self.CheckProcess(False) except autoit.autoit.AutoItError: pass
def CheckWindow(): while True: try: message = autoit.control_get_text( "[CLASS:#32770]", "[CLASS:msctls_statusbar32; INSTANCE:1]") if message == "Nothing found": autoit.win_close("On-Demand Scan Progress") except autoit.autoit.AutoItError: #os.system("powershell.exe Start-Process powershell.exe -ArgumentList C:\\Fuzzing\\ScanEngine\\Restart.ps1") CheckWindow()
def CheckWindow(): #autoit.run("C:\\Program Files (x86)\\McAfee\\VirusScan Enterprise\\x64\\Scan64.Exe") #autoit.win_wait_active("On-Demand Scan Progress",3) while True: try: message = autoit.control_get_text( "[CLASS:#32770]", "[CLASS:msctls_statusbar32; INSTANCE:1]") if message == "Nothing found": autoit.win_close("On-Demand Scan Progress") except autoit.autoit.AutoItError: os.system( "powershell.exe Start-Process powershell.exe -ArgumentList C:\\Fuzzing\\ScanEngine\\Restart.ps1" ) CheckWindow()
def get_text(self, control: str, *, timeout=15, focus=True): ctrl_txt = None timer = Timer(timeout) while timer.not_expired: try: if focus: autoit.control_focus(self.title, control) ctrl_txt = autoit.control_get_text(self.title, control) if isinstance(ctrl_txt, str): return ctrl_txt except Exception as e: # print(f"[Exception]--> {e}") pass if timer.expired: return -1
def controlGetText(self, control): ''' :description 获取指定控件上的文本. :return 文本内容:成功; 空:失败. ''' return autoit.control_get_text(self.title, control, text=self.text)
def controlGetText(self, control): """获取控件上的文本""" return autoit.control_get_text(self.title, control, text=self.text)
scanpstPath = 'C:\Program Files (x86)\Microsoft Office\Office15\SCANPST.EXE' # path of SCANPST scanpstTitle = '[CLASS:#32770]' # title of SCANPST for pstPath in glob.glob('D:\mail\*.pst'): print("Processing %s" % pstPath) autoit.run(scanpstPath) # open exe user_control_wait_text(scanpstTitle, "Static2", '請輸入您要掃描的檔案名稱') # wait win active (background handle) #autoit.win_set_state(scanpstTitle, autoit.autoit.Properties.SW_SHOWNOACTIVATE) autoit.control_set_text(scanpstTitle, "Edit1", pstPath) # set pst path autoit.control_click(scanpstTitle, "Button2") # 啟動 user_control_wait_text(scanpstTitle, "Static2", pstPath) # wait scan finish # judgement result rstMsg = autoit.control_get_text(scanpstTitle, "Static3") print(rstMsg) if '沒有在這個檔案中找到錯誤' in rstMsg: autoit.control_click(scanpstTitle, "Button5") # 確定 else: # if need to fix autoit.control_click(scanpstTitle, "Button1") # 取消勾選備份 autoit.control_click(scanpstTitle, "Button4") # 修復 fixMsg = '修復完成' user_control_wait_text(scanpstTitle, "Static2", fixMsg) autoit.control_click(scanpstTitle, "Button1") # 確定 print(fixMsg) print("") # new line
import time import autoit from webdriver_manager.chrome import ChromeDriverManager from selenium import webdriver driver = webdriver.Chrome(ChromeDriverManager().install()) driver.maximize_window() driver.get('https://my.indeed.com/resume?from=bottomResumeCTAhomepage&trk.origin=homepage&co=IN&hl=en_IN&obo=https%3A%2F%2Fwww.indeed.co.in') driver.find_element_by_xpath('//button[@type="button" and text()="Upload your resume"]').click() time.sleep(10) autoit.control_focus("Open","Edit1") time.sleep(5) autoit.control_set_text("Open","Edit1","C:\\Users\\Dusa\\Downloads\\SatheeshKumar.doc") print(autoit.control_get_text("Open","Button2")) time.sleep(3) autoit.control_click("Open","Button1") from pywinauto.application import Application from selenium.webdriver.common.keys import Keys #app=Application().connect(process=get_pid()) #app.FileUpload.Edit.SetText('C:/Users/Dusa/Downloads/Satheesh Kumar.doc') #time.sleep(3) #app.FileUpload.Buttton.click()