示例#1
0
def send_attachment():
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)

    # To send Videos and Images.
    mediaButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
    )
    mediaButton.click()
    time.sleep(3)

    hour = datetime.datetime.now().hour

    # After 5am and before 11am scheduled this.
    if (hour >= 5 and hour <= 11):
        image_path = os.getcwd() + "\\Media\\" + 'goodmorning.jpg'
    # After 9pm and before 11pm schedule this
    elif (hour >= 21 and hour <= 23):
        image_path = os.getcwd() + "\\Media\\" + 'goodnight.jpg'
    else:  # At any other time schedule this.
        image_path = os.getcwd() + "\\Media\\" + 'howareyou.jpg'
    # print(image_path)

    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", (image_path))
    autoit.control_click("Open", "Button1")

    time.sleep(3)
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    whatsapp_send_button.click()
示例#2
0
def InformarLote(Qtd):
    time.sleep(Variaveis.TEnter)
    log.EscreverLog('Informar Lote')
    autoit.send("{CTRLDOWN}l{CTRLUP}")
    time.sleep(Variaveis.TDig)
    autoit.win_wait_active("[Class:TFRM_OBRIGAITENSLOTE]", Variaveis.TTelaL)
    time.sleep(Variaveis.TDig)
    time.sleep(Variaveis.TEnter)
    autoit.control_click("[Class:TFRM_OBRIGAITENSLOTE]", "TVSMColorButton1")
    time.sleep(Variaveis.TEnter)
    log.EscreverLog('Selecionar Lote')
    time.sleep(Variaveis.TDig)
    autoit.win_wait_active("[Class:TFRM_ITENSLOTE]", Variaveis.TTelaL)
    time.sleep(Variaveis.TDig)
    autoit.send(Qtd)
    time.sleep(Variaveis.TEnter)
    autoit.send("{ENTER}")
    time.sleep(Variaveis.TEnter)
    time.sleep(Variaveis.TDig)
    autoit.control_click("[Class:TFRM_ITENSLOTE]", "TVSMColorButton1")
    time.sleep(Variaveis.TEnter)
    time.sleep(Variaveis.TDig)
    autoit.send("{ENTER}")
    time.sleep(Variaveis.TEnter)
    time.sleep(Variaveis.TFinal)
示例#3
0
 def clean_dlg(self):
     try:
         if autoit.win_exists(self.wid_prompt):
             autoit.win_activate(self.wid_prompt)
             autoit.control_click(self.wid_prompt, self.cid_prompt_ok)
     except autoit.AutoItError:
         pass
示例#4
0
 def post(self, image, caption, hashtags):
     self.driver.find_element_by_xpath(
         '//div[contains(@class, "q02Nz _0TPg")]').click()  # click new post
     # go to the popped up open browser to select the image
     handle = "[CLASS:#32770; TITLE:Open]"
     autoit.win_wait(handle, 60)
     sleep(1)
     autoit.control_set_text(handle, "Edit1",
                             '{}\{}'.format(images_path, image))
     sleep(2)
     autoit.control_click(handle, "Button1")
     sleep(2)
     # expand the image
     self.driver.find_element_by_xpath(
         '//button[contains(@class, "pHnkA")]').click()
     sleep(2)
     # click next
     self.driver.find_element_by_xpath(
         "//button[contains(text(),'Next')]").click()
     sleep(3)
     # add caption
     self.driver.find_element_by_xpath(
         '//*[@id="react-root"]/section/div[2]/section[1]/div[1]/textarea'
     ).click()
     self.driver.find_element_by_xpath(
         '//*[@id="react-root"]/section/div[2]/section[1]/div[1]/textarea'
     ).send_keys('{}\n\n{}'.format(caption, ' '.join(hashtags)))
     sleep(2)
     # click share button
     self.driver.find_element_by_xpath(
         '//button[contains(text(), "Share")]').click()
示例#5
0
    def test_pcLogin(self):
        fp = webdriver.FirefoxProfile(r"C:\Users\mhf\AppData\Roaming\Mozilla\Firefox\Profiles\cv6txwo2.default")
        driver = webdriver.Firefox(fp)
        # driver = webdriver.Firefox ()
        driver.get ("https://www.hongkunjinfu.com")
        WebDriverWait (driver, 10).until (EC.presence_of_element_located ((By.ID, 'login')))
        driver.find_element_by_id ('login').send_keys ('14510000051')
        #保存网页弹出框
        driver.find_element_by_id('login').send_keys(Keys.CONTROL+'s')
        time.sleep(2)
        # autoit.run("notepad.exe")
        # autoit.win_wait_active("[CLASS:Notepad]", 3)
        # autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
        # autoit.win_close("[CLASS:Notepad]")
        # autoit.control_click("[Class:#32770]", "Button2")
        # autoit.win_wait
        # autoit.win_wait_active("[CLASS:#32770]",3)
        autoit.win_activate('另存为')
        print("111111")
        autoit.control_focus('另存为','1001')
        print("22222222")
        autoit.win_wait("[Class:#32770]",10)

        autoit.control_set_text('另存为','Edit1','金服网页2')

        # autoit.control_send("[CLASS:#32770]", "Edit1", "hello world{!}")
        # autoit.control_click("[CLASS:#32770]", "Button2")
        autoit.control_click('另存为','Button2')
        driver.close()
def send_attachment(image_path):
    try:
        # Attachment Drop Down Menu
        clipButton = driver.find_element_by_xpath(
            '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
        clipButton.click()
        time.sleep(1)

        # To send Videos and Images.
        mediaButton = driver.find_element_by_xpath(
            '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button'
        )
        mediaButton.click()
        time.sleep(3)

        autoit.control_focus("Open", "Edit1")
        autoit.control_set_text("Open", "Edit1", (image_path))
        autoit.control_click("Open", "Button1")
        time.sleep(6)

        whatsapp_send_button = driver.find_element_by_xpath(
            '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
        )
        whatsapp_send_button.click()
    except Exception as e:
        print(e)
示例#7
0
    def Install_CQI(self):
        autoit.auto_it_set_option("MouseClickDelay", 1000)
        autoit.run(
            "D:\CareFusion\CQI 4.3\Release\Guardrails CQI - Setup-4.3.exe")

        window_name = "[Class:MsiDialogCloseClass]"
        autoit.win_wait_active(window_name, 30)

        autoit.control_wait_visible(window_name, "[ID:2271]", 30)
        autoit.control_click_wait(window_name, "[ID:2271]",
                                  20)  # Welcome screen - Next

        autoit.control_click_wait(window_name, "[ID:2172]",
                                  20)  # License screen - Accept Rad Button
        autoit.control_wait_enabled(
            window_name, "[ID:2271]",
            30)  # Wait till Next Button is enabled after accepting
        autoit.control_click(window_name, "[ID:2271]")  # License screen - Next

        autoit.control_wait_enabled(window_name, "[ID:2271]",
                                    30)  # Language screen - Next
        autoit.control_wait_visible(window_name, "[ID:2271]", 30)
        autoit.control_click(window_name,
                             "[ID:2271]")  # Language screen - Next

        autoit.control_wait_visible(window_name, "[ID:2271]",
                                    30)  # SetupType screen - Next
        autoit.control_custom_sleep(
            2000)  # Sometimes the event is missed. Needs a delay first.
        autoit.control_click_wait(window_name, "[ID:2271]",
                                  10)  # SetupType screen - Next
 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
示例#9
0
    def test_pcLogin(self):
        fp = webdriver.FirefoxProfile(r"C:\Users\mhf\AppData\Roaming\Mozilla\Firefox\Profiles\cv6txwo2.default")
        driver = webdriver.Firefox(fp)
        # driver = webdriver.Firefox ()
        driver.get ("https://www.hongkunjinfu.com")
        WebDriverWait (driver, 10).until (EC.presence_of_element_located ((By.ID, 'login')))
        driver.find_element_by_id ('login').send_keys ('14510000051')
        driver.find_element_by_xpath("html/body/div[2]/div[2]/div/ul/li[1]/a").click()

        autoit.win_activate('鸿坤金服——社区金融超市 - Mozilla Firefox')
        print("1111")
        autoit.send('{LCTRL down}'+'{LSHIFT down}'+'{! down}')
        # autoit.send('{LCTRL down}' + '{LALT down}' + '{a down}')
        # driver.find_element_by_id('login').send_keys(Keys.CONTROL + Keys.SHIFT + '!')
        time.sleep(2)
        autoit.win_wait('截取的图片另存为...')
        print("2222")
        autoit.control_focus('截取的图片另存为...','1001')
        print("3333")
        autoit.win_wait("[Class:#32770]",10)
        t = datetime.now().strftime('%Y%m%d%H%M%S')
        name='金服首页'+t
        # autoit.control_set_text('截取的图片另存为...','Edit1','金服网页102')
        autoit.control_set_text('截取的图片另存为...','Edit1',name)
        autoit.control_click('截取的图片另存为...','Button2')
        driver.close()
示例#10
0
def send_files():
    global doc_filename
    # Attachment Drop Down Menu
    clipButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/div/span')
    clipButton.click()
    time.sleep(1)

    # To send a Document(PDF, Word file, PPT)
    docButton = browser.find_element_by_xpath(
        '//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[3]/button'
    )
    docButton.click()
    time.sleep(1)

    docPath = os.getcwd() + "\\Documents\\" + doc_filename

    autoit.control_focus("Open", "Edit1")
    autoit.control_set_text("Open", "Edit1", (docPath))
    autoit.control_click("Open", "Button1")

    time.sleep(3)
    whatsapp_send_button = browser.find_element_by_xpath(
        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div/span'
    )
    whatsapp_send_button.click()
示例#11
0
文件: login.py 项目: bopopescu/DevsON
    def Crtx(self):
        log.EscreverLog('Função CRTX')
        log.EscreverLog('ESC')
        autoit.send("{ESC}")
        log.EscreverLog('Timer ' + str(Variaveis.TDig))
        time.sleep(Variaveis.TDig)

        log.EscreverLog('ESC')
        autoit.send("{ESC}")
        log.EscreverLog('Timer ' + str(Variaveis.TDig))
        time.sleep(Variaveis.TDig)

        log.EscreverLog('Limpa Tela')
        autoit.send("{CTRLDOWN}x{CTRLUP}")
        log.EscreverLog('Timer ' + str(Variaveis.TDig))
        time.sleep(Variaveis.TDig)
        try:
            log.EscreverLog('Tempo.do alerta sem Produto ' + 'Timer ' +
                            str(Variaveis.TTela))
            autoit.win_wait_active("[Class:TFRM_VSMTASKDIALOG]",
                                   Variaveis.TTela)
            log.EscreverLog('Botão Ok')

            autoit.control_click("[Class:TFRM_VSMTASKDIALOG]", "TRzBitBtn1")
            log.EscreverLog('Clicou Ok')
            log.EscreverLog('Timer ' + str(Variaveis.TDig))
            time.sleep(Variaveis.TDig)
        except:
            log.EscreverLog('Não teve Alerta, Limpando tela')

        log.EscreverLog('Enter')
        autoit.send("{ENTER}")
        log.EscreverLog('Timer ' + str(Variaveis.TEnterR))
        time.sleep(Variaveis.TEnter)
        log.EscreverLog('Sai Função CRTX')
示例#12
0
def command_thor_test(command):
    try:
        ai.win_activate('[title:Control a Device]')
    except ai.AutoItError:
        print('AutoItError happened, returned')
        return
    time.sleep(0.1)
    ai.control_focus('[title:Control a Device]','Edit8')
    time.sleep(0.1)
    ai.control_set_text('[title:Control a Device]','Edit8',command)
    time.sleep(1)
    ai.control_click('[title:Control a Device]','Button15')  #clear the command window
    time.sleep(0.5)
    ai.control_click('[title:Control a Device]','Button13')  #send the command work
    time.sleep(2)
    ai.win_activate('[title:NetLinx Studio]')
    time.sleep(1)
    count = 0
    while True:
        count+=1
        print('try '+str(count)+' time')
        out = get_comeback_message()
        if out!='':
            print('congratulations! the output is not empty')
            break
        elif count<=3:
            time.sleep(3)
        else:
            print('even tried 4 times, the output is still empty')
            break
    return out
#%% test the function
#haha=command_thor_test('get status')        
#print(haha)
示例#13
0
def PedeCPF():
    sSql = "SELECT COALESCE(CF.STATUS,'S') " \
           "FROM myouro.LOJAS L " \
           "INNER JOIN myouro.CIDADES C ON C.CODCID = L.CODCID " \
           "LEFT JOIN myouro.CONFIGURACAO CF ON CF.CHAVE = CONCAT(C.UFCID,'_PEDECPF') " \
           "WHERE L.CODLOJA  = %s " % (Variaveis.CodLoja)

    log.EscreverLog('Executando Sql:' + str(sSql))
    Resultado = FuncoesBD.ComDBSlave.Select(str(sSql))

    if Resultado.__len__() > 0:
        Result = Resultado[0]
        Variaveis.PedeCpf = str(Result[0])

    if Variaveis.PedeCpf == 'S':
        log.EscreverLog("Função Pede CPF")
        try:
            Tempo.TeclaAcao()
            autoit.win_wait_active("[Class:TFRM_VENDACPF]", Variaveis.Tempo)
            log.EscreverLog("Pede CPF")
            autoit.control_click("[Class:TFRM_VENDACPF]", "TVSMColorButton3")
            log.EscreverLog("Fecha Pede CPF")
        except:
            log.EscreverLog('Não pediu CPF')
    if Variaveis.PedeCpf == 'N':
        log.EscreverLog('Não pediu CPF')
        Tecla.TempoM()
示例#14
0
    def upload(self, filePath):
        xx = filePath[1:2]
        print(xx)
        if (filePath[1:2] != ':'):
            #是相对路径 要到files下面去找
            pwd = os.getcwd()
            tmp = pwd.split("src")[0]
            tmp = os.path.abspath(tmp + os.path.sep + "..") + "\\files"

            filePath = filePath.replace("/", "\\")
            if (not filePath.startswith("\\")):
                filePath = "\\" + filePath
            filePath = tmp + filePath

        dirPath = os.path.dirname(filePath)
        if (not dirPath.endswith('\\')):
            dirPath = dirPath + '\\'

        l = len(dirPath)
        fileName = filePath[l:]

        #下面开始是在上传对话框上的操作
        time.sleep(1)
        autoit.win_active("打开")
        autoit.control_set_text("打开", "Edit1", dirPath)

        time.sleep(0.5)

        autoit.control_click("打开", "Button1")

        time.sleep(3)

        autoit.control_set_text("打开", "Edit1", fileName)

        autoit.control_click("打开", "Button1")
示例#15
0
    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)
示例#16
0
def add_data_shp():    #加载矢量数据shp格式
    autoit.mouse_click("left",120,92,1)                                #点击加载矢量数据
    autoit.win_wait_active(u"打开矢量文件",15)
    autoit.control_set_text(u"打开矢量文件","Edit1",r"C:\Users\admin\Desktop\PIEDATA\Lambert_SHP\beijing.shp")
    autoit.control_click(u"打开矢量文件","Button1")                    #选择好文件,点击打开
    autoit.win_wait_active(u"提示",5)                                  #不同坐标系,提示是否新建图层
    autoit.control_click(u"提示","Button2")                            #新建图层
    sleep(5)
示例#17
0
def click_ClearList():
    try:
        ai.win_activate('[title:ICSPMonitor - V7.2.115]')
    except ai.AutoItError:
        #print('AutoItError happened, returned')
        logger.prt.debug('AutoItError happened,could not detect ICSPMonitor Window, returned')
        return
    time.sleep(0.1)
    ai.control_click('[title:ICSPMonitor - V7.2.115]','Button4')
示例#18
0
def PgtoAntecipado():
    time.sleep(Variaveis.TEnter)
    log.EscreverLog('Função Pgto Antecipado')
    log.EscreverLog("Entregador")
    autoit.control_click("[Class:TFRM_DADOSENTREGA]", "TVSMGroupButton7")
    time.sleep(Variaveis.TEnter)
    autoit.control_click("[Class:TFRM_DADOSENTREGA]", "TVSMGroupButton1")
    time.sleep(Variaveis.TEnter)
    log.EscreverLog('Sai Pgto Antecipado')
示例#19
0
 def file_upload(window_name, file_name):
     autoit.win_wait(window_name, 30)
     if not autoit.win_exists(window_name):
         raise Exception("No File Upload Window is found")
     else:
         autoit.win_activate(window_name)
         autoit.control_focus(window_name, "[ID:1148]")
         autoit.control_set_text(window_name, "[ID:1148]", file_name)
         autoit.control_click(window_name, "[ID:1]")
示例#20
0
 def download_image(self):
     self.button_choose = self.find.element_by_xpath(lk_conf.button_choose_xpath).click()
     sleep(1)
     autoit.win_wait(lk_conf.autoit_title, lk_conf.autoit_wait)
     autoit.control_focus(lk_conf.autoit_title, lk_conf.autoit_control_edit)
     autoit.control_send(lk_conf.autoit_title, lk_conf.autoit_control_edit, lk_conf.autoit_image_path)
     autoit.control_click(lk_conf.autoit_title, lk_conf.autoit_control_button)
     self.find.element_by_xpath(lk_conf.button_download_xpath).click()
     sleep(3)
示例#21
0
def add_data_jpg():  #加载栅格数据jpg格式
    '''添加数据方法一:设置焦点进行传参,添加jpg数据'''
    autoit.mouse_click("left",54,92,1)                                     #点击加载栅格数据
    autoit.win_wait_active(u"打开栅格文件",15)                              #等待窗口活跃,15秒超时
    autoit.control_focus(u"打开栅格文件", "[Class:Edit; instance:1]")       #设置焦点
    autoit.control_set_text(u"打开栅格文件", "[Class:Edit; instance:1]","C:\Users\Administrator\Desktop\GF1.jpg")
    # 输入文本
    autoit.control_click(u"打开栅格文件", "Button1")
    sleep(5)
示例#22
0
def test_upload_file2(driver):
    file = driver.find_element_by_xpath(
        "//label[text()='点击上传']/..//div//span").click()
    sleep(3)
    autoit.control_set_text("打开", "Edit1",
                            "C:\\Users\\admin\\Desktop\\hillway.png")
    sleep(3)
    autoit.control_click("打开", "Button1")
    pass
示例#23
0
 def controlClick(self, control, button="main", clicks=1):
     '''
     :description 向指定控件发送鼠标点击命令.
     '''
     autoit.control_click(self.title,
                          control,
                          text=self.text,
                          button=button,
                          clicks=clicks)
示例#24
0
def right_control():  # 图层右键功能
    autoit.mouse_click("Right", 93, 193, 1, 10)  # 右键点击图层,打开功能列表
    sleep(1)
    autoit.send("{down 10}")  # 选择第十行,选择属性
    sleep(1)
    autoit.send("{enter}")
    autoit.win_wait_active(u"图层属性", 5)  # 等待图层属性窗口,5秒超时
    sleep(1)
    autoit.control_click(u"图层属性", "Button2")  # 关闭图层属性
    sleep(1)
示例#25
0
 def click(self, locator):
     """
     Clicks on an element identified by locator
     :param locator: user defined name from map files
     Ex: click("locator_name")
     """
     locator = self.__get_locator_for_tool(locator)
     window_identifier, control_identifier = mapMgr.__getitem__(
         locator)["IDENTIFIERS"].strip("'").split(",")
     autoit.control_click(window_identifier, control_identifier.strip('"'))
示例#26
0
def TelaAlerta(t, e):
    try:
        Variaveis.Tempo = (5)
        autoit.win_wait_active("[Class:TFRM_VSMTASKDIALOG]", Variaveis.Tempo)
        Tempo.Click()
        log.EscreverLog(str(t))
        autoit.control_click("[Class:TFRM_VSMTASKDIALOG]", "TVSMColorButton1")
        log.EscreverLog('Clicou Ok')
    except:
        log.EscreverLog(str(e))
    Tempo.TeclaAcao()
示例#27
0
def add_data_tif():  # 加载栅格数据Tif格式,此格式是否需要建立金字塔
    '''添加数据方法二:直接使用control_set_text传参,添加tif数据是否建立金字塔'''
    autoit.mouse_click("left", 50, 92, 1)  # 点击加载栅格数据
    autoit.win_wait_active(u"打开栅格文件", 15)
    autoit.control_set_text(u"打开栅格文件", "Edit1",
                            r"C:\Users\admin\Desktop\PIEDATA\GF1.tiff")
    autoit.control_click(u"打开栅格文件", "Button1")  # 确定打开文件
    autoit.win_wait_active(u"建立金字塔", 5)  # 等待是否建立金字塔窗口
    autoit.control_click(u"建立金字塔", "Button3")  # 取消建立金字塔
    sleep(10)
    '''添加数据方法三:使用control_send传参,添加tif数据是否建立金字塔'''
示例#28
0
文件: Tela.py 项目: bopopescu/DevsON
def AlertaRejeicao():
    log.EscreverLog('Tela de Alerta')
    try:
        Variaveis.Tempo = (Variaveis.TempoAddFinalVenda + 5)
        log.EscreverLog('Tempo ate ' + str(Variaveis.Tempo) + ' segundos')
        autoit.win_wait_active("[Class:TFRM_VSMTASKDIALOG]", Variaveis.Tempo)
        Tempo.EnterProduto()
        autoit.control_click("[Class:TFRM_VSMTASKDIALOG]", "TVSMColorButton1")
        log.EscreverLog('Clicou Ok')
    except:
        Tempo.EnterProduto()
示例#29
0
 def click_ac_upload(self, index, path):
     """
     单击上传按钮;通过索引来决定点击哪个上传功能
     :param index: 索引为找到元素索引
     :param path: 上传图片所在绝对路径
     :return:
     """
     self.click_btn_index('上传', index, *(self.activity_upload_locs))
     #autoit处理
     autoit.control_set_text('打开', '[Class:Edit; instance:1]', path)
     autoit.control_click('打开', '[Class:Button; INSTANCE:1]')
示例#30
0
        def sendAttachment():
            global imagename
            if imagename:
                if ',' not in imagename:
                    # Attachment Drop Down Menu
                    clipButton = browser.find_element_by_xpath(
                        '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/div[1]/span'
                    )
                    clipButton.click()
                    time.sleep(1)

                    # To send Videos and Images.
                    mediaButton = browser.find_element_by_xpath(
                        '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/span/div/div/ul/li[1]/button'
                    )
                    mediaButton.click()
                    time.sleep(3)
                    imagePath = os.getcwd(
                    ) + "\\AlWhatsApp\\Documents\\" + imagename
                    autoit.control_focus("Open", "Edit1")
                    autoit.control_set_text("Open", "Edit1", (imagePath))
                    autoit.control_click("Open", "Button1")
                    time.sleep(3)
                    whatsapp_send_button = browser.find_element_by_xpath(
                        '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div/div/span'
                    )
                    whatsapp_send_button.click()
                if ',' in imagename:
                    imagename = imagename.split(',')
                    for i in imagename:
                        # Attachment Drop Down Menu
                        clipButton = browser.find_element_by_xpath(
                            '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/div[1]/span'
                        )
                        clipButton.click()
                        time.sleep(1)

                        # To send Videos and Images.
                        mediaButton = browser.find_element_by_xpath(
                            '//*[@id="main"]/footer/div[1]/div[1]/div[2]/div[1]/span/div/div/ul/li[1]/button'
                        )
                        mediaButton.click()
                        time.sleep(3)
                        imagePath = os.getcwd(
                        ) + "\\AlWhatsApp\\Documents\\" + i
                        autoit.control_focus("Open", "Edit1")
                        autoit.control_set_text("Open", "Edit1", (imagePath))
                        autoit.control_click("Open", "Button1")
                        time.sleep(3)
                        whatsapp_send_button = browser.find_element_by_xpath(
                            '//*[@id="app"]/div/div/div[2]/div[2]/span/div/span/div/div/div[2]/span/div/div/span'
                        )
                        whatsapp_send_button.click()
示例#31
0
def gettime():
	# Clear all previous calculate windows
	prfin = autoit.win_exists("[Title:"+calctitle+"]")
	while prfin:
		autoit.control_click("[Title:"+calctitle+"]", "Button1", clicks=2)
		prfin = autoit.win_exists("[Title:"+calctitle+"]")

	# Create updated calculate window
	autoit.control_click("[Title:"+maintitle+"]", "ToolbarWindow321", x=185, y=7)
	prfin = autoit.win_exists("[Title:"+calctitle+"]")
	while not prfin:
		prfin = autoit.win_exists("[Title:"+calctitle+"]")

	# Read calculate window and get hms data
	unparsed = autoit.win_get_text("[Title:"+calctitle+"]")
	while not unparsed:
		unparsed = autoit.win_get_text("[Title:"+calctitle+"]")
	regfind = worktime.search(unparsed).group()
	(h, m, s) = regfind.split(':')

	# Close calculate window
	autoit.control_click("[Title:"+calctitle+"]", "Button1", clicks=2)
	
	# Return seconds
	return int(h)*3600 + int(m)*60 + int(s)
示例#32
0
    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
示例#33
0
    def add_file(self, resource):
        # Open an add file window
        autoit.win_wait_active(WINDOW_MAIN)
        autoit.control_click(WINDOW_MAIN, BUTTON_ADD_FILE)

        # Open a file
        autoit.win_wait_active(WINDOW_OPEN)
        autoit.control_set_text(WINDOW_OPEN, FORM_FILE, resource.ts_file)
        autoit.control_click(WINDOW_OPEN, BUTTON_OPEN)

        # .............
        # Choose a clip
        # .............

        # Fill a clip name
        autoit.win_wait_active(WINDOW_EDIT)
        autoit.control_set_text(WINDOW_EDIT, FORM_CLIP_NAME, resource.name)
        autoit.control_click(WINDOW_EDIT, BUTTON_OK)
示例#34
0
# -*- coding: utf-8 -*-

__author__ = 'Jace Xu'

import autoit

autoit.run("notepad.exe")
autoit.win_wait_active("[CLASS:Notepad]", 3)
autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
autoit.win_close("[CLASS:Notepad]")
autoit.control_click("[Class:#32770]", "Button2")
示例#35
0
 def open_new_project(self):
     autoit.control_click(WINDOW_START, BUTTON_NEW_PROJECT)
     autoit.win_wait_active(WINDOW_MAIN)
示例#36
0
def main():

    user_dir = get_users_main_directory()
    check_lp_power_data_folder_exists(user_dir)
    check_database_file_exists(user_dir)
    trial = {}
    trial = prompt_setup(trial, user_dir)

    # stopgap for pre-class variables
    walk_speed = trial["Speed [MPH]"]
    walk_style = trial["Walk Style [Normal/LP]"]
    pack_number = trial["Pack Number [XXX]"]

    # MAKE FOLDERS FOR TRIAL BASED ON PREVIOUSLY-ENTERED INPUTS
    make_pack_folder(pack_number, walk_speed, walk_style, user_dir)

    print('.....')
    print("..........Launching.....")

    # SET UP BASIC AUTO-IT SETTINGS TO USE WINDOW-RELATIVE COORDINATES
    autoit.auto_it_set_option('MouseCoordMode', 0)
    autoit.auto_it_set_option('SendKeyDelay', 10)

    # OPEN PICOSCOPE USING OUR DEFAULT WINDOW LAYOUT WITH TWO PANELS AND POWER UP TOP
    default_pico = os.path.join(user_dir, "electrical_power.psdata")
    click_on_file(default_pico)

    # PREPARE TO RUN THE RECORD DATA MACRO
    autoit.win_wait('PicoScope 6 - [electrical_power.psdata]')
    autoit.win_activate('PicoScope 6 - [electrical_power.psdata]')
    time.sleep(0.5)
    autoit.send('{ALT}{TAB}{TAB}{TAB}{TAB}{ENTER}{END}{UP}{ENTER}')
    autoit.win_wait('Macro Recorder')
    autoit.control_click('Macro Recorder', "[Name:_buttonImport]")
    time.sleep(1)
    macro_text = os.path.abspath(os.path.join(user_dir, "record_20sec.psmacro"))
    autoit.clip_put(macro_text)
    autoit.win_wait("Open")
    autoit.send('^V', 0)
    autoit.send('{ENTER}')
    msgbox("Ready to go?")

    # RUN THE MACRO
    autoit.win_activate('Macro Recorder')
    autoit.win_wait('Macro Recorder')
    autoit.control_click('Macro Recorder', "[Name:_buttonExecute]")
    time.sleep(22)
    autoit.win_activate('Macro Recorder')
    autoit.send('{ESCAPE}')

    # BEGIN SAVING THE DATA
    i = datetime.now()
    save_text = os.path.abspath(os.path.join(user_dir, 'LP Power Data', "{}".format("LP-{0}".format(pack_number)), "{0}MPH-{1} Walk".format(walk_speed, walk_style),
                             "{0}MPH-{1} Walk_".format(walk_speed, walk_style) + i.strftime('%Y-%m-%d %Hh%Mm%Ss')+ ".psdata"))
    autoit.clip_put(save_text)

    # SAVE ALL CAPTURED WAVEFORMS IN PICO FORMAT
    autoit.win_activate('PicoScope 6')
    autoit.win_wait("PicoScope 6")
    autoit.send('{ALT}{f}{a}')
    time.sleep(.5)
    autoit.win_wait("Save As")
    autoit.control_send('Save As', "[Class:Edit;INSTANCE:1]", '^V', 0)
    autoit.send('{ENTER}')

    # BEGIN SAVE SEQUENCE FOR CSV FORMAT
    autoit.win_activate('PicoScope 6')
    autoit.win_wait("PicoScope 6")
    autoit.mouse_click("primary", 433, 67, 2, 1)
    # MUST CLICK ON SECTION OF WINDOW CONTAINING POWER TRACE OR ALL AVERAGES CALCULATED WILL BE MESSED UP
    autoit.win_activate('PicoScope 6')
    autoit.win_wait("PicoScope 6")
    autoit.mouse_click("primary", 230, 260, 1, 0)
    # autoit.control_click('PicoScope 6', "[CLASS:WindowsForms10.Window.8.app.0.1114f81_r13_ad1; INSTANCE:55]")
    autoit.send('{ALT}{f}{a}')
    time.sleep(.5)
    autoit.win_wait("Save As")
    autoit.control_send('Save As', "[Class:Edit;INSTANCE:1]", '^V', 0)

    # SAVE ALL CAPTURED 5SEC INTERVALS
    autoit.control_click('Save As', "[CLASS:ComboBox;INSTANCE:3]")
    autoit.send("{HOME}{DOWN}{DOWN}{ENTER}")
    # autoit.control_click("Save As", "[NAME:_currentBufferRadio]")
    time.sleep(0.5)
    autoit.send('{ENTER}')
    time.sleep(4.5)
    autoit.process_close('PicoScope.exe')
    # BOTH SAVE OPERATIONS NOW COMPLETE. THERE IS A CSV FOR EACH 5SEC INTERVAL IN A NEW SUBDIRECTORY OF THIS TRIAL.

    print("")
    print("Sit tight, I'm still doing some thinking....")

    # UPDATE ALL CSV FILES TO BE XLSX AND CALCULATE THEIR 5SEC AVERAGES
    run_avgs = recursively_repair_all_csv_files(save_text, user_dir, walk_speed)

    # ADD ALL INFORMATION COLLECTED TO THE EXPERIMENTS SPREADSHEET
    patch_experiments_database(trial, run_avgs, user_dir)
    print("")

    # WRITE THE METADATA SETTINGS TO A FILE FOR FUTURE RECORD
    with open('{}'.format(save_text.replace(".psdata", ".LPmeta")), 'w') as outfile:
        json.dump(trial, outfile, indent=4, separators=(',', ': '))
    print("")
    print("LP Metadata file successfully saved for the future with all info the state of the pack as you have just tested it.")

    print("")
    # print_average_power(dest_filename)
    print(".................................. Testing Complete.")