Пример #1
0
    def test_completed(self):
        app = application.Application()
        app.connect(title_re="1С:Предприятие")
        app_1c = app['1С:Предприятие - Торговля+Склад, редакция 9.2']
        w1 = app_1c.child_window(title="Окно сообщений")
        w1.set_focus()

        # click_getStockEntryList(app)
        app_1c = app['1С:Предприятие - Торговля+Склад, редакция 9.2']
        app_1c.menu_select("ВСД -> Обработки")
        app_1c.child_window(title="Реализации").click()
        app_1c.child_window(title="Загрузить Партии").click()
        app['Загрузить партии с :'].OK.click()
        time.sleep(10)

        left, top = get_center(w1, 10)
        mouse.click(coords=(left, top))
        print("Клик = ", left, top)

        mouse.click(coords=(left, top))
        # time.sleep(0.2)
        send_keys('^{HOME}')
        send_keys('+^{END}')
        send_keys('^{INSERT}')
        data = clipboard.GetData()
        s = data.split('\n')
        print(s[-2])
        print(s[-1])
        # self.assertEqual(s[-2], 'Результат = COMPLETED\r')
        self.assertIn('Результат = COMPLETED\r', s)
Пример #2
0
 def restart(self):
     self.spec.set_focus()
     rect = self.spec.rectangle()
     print(rect)
     loc = find_image(IMG_LOC + "/exit.png", rect=rect)
     if loc is not None:
         x_left = self.spec.rectangle().left
         y_top = self.spec.rectangle().top
         while x_left < -10 or y_top < -10:
             x_left = self.spec.rectangle().left
             y_top = self.spec.rectangle().top
             time.sleep(0.25)
         x = loc[0] + x_left
         y = loc[1] + y_top
         mouse.click(coords=(x, y))
         print("clicked x")
         time.sleep(0.5)
         keyboard.send_keys("{ENTER}")
         time.sleep(10)
         self.app = Application().start(self.RS3_loc)
         self.spec = None
         self.spec_connected = False
         self.spec = self.app.ThunderRT6Form
         self.spec.draw_outline()
         self.pid = self.app.process
         self.menu = RS3Menu(self.app)
     else:
         print("Error: Failed to restart RS3")
Пример #3
0
    def test(self):
        app = application.Application()
        app.connect(title_re="1С:Предприятие")
        app_1c = app['1С:Предприятие - Торговля+Склад, редакция 9.2']
        # app_1c.menu_select("ВСД -> ВСД_Партии")
        # app_1c.child_window(title="Справочник: ВСД_Партия").print_control_identifiers()

        p1 = app_1c.child_window(title="Справочник: ВСД_Партия").child_window(
            class_name="browse")
        p1.set_focus()
        left, top = get_pos(p1, 30)
        mouse.double_click(coords=(left, top))
        app_1c.child_window(title='Обновить из Меркурия').click()
        send_keys('{ENTER}')

        w1 = app_1c.child_window(title="Окно сообщений")
        w1.set_focus()
        left, top = get_center(w1, 10)
        mouse.click(coords=(left, top))
        print("Клик = ", left, top)

        mouse.click(coords=(left, top))
        # time.sleep(0.2)
        send_keys('^{HOME}')
        time.sleep(0.2)
        send_keys('+^{END}')
        send_keys('^{INSERT}')
        data = clipboard.GetData()
        s = data.split('\n')
        # print(s[-2])
        # print(s[-1])
        # self.assertEqual(s[-2], 'Результат = COMPLETED\r')
        self.assertIn('Результат = COMPLETED\r', s)
Пример #4
0
 def programme_rj(self):
     # 实例化一个Options
     chrome_options = Options()
     # 用于定义下载不弹窗和默认下载地址(默认下载地址还要再后面的commands里启动,默认是不开启的)
     prefs = {
         "download.default_directory": self.get_desktop() + "\\",
         "download.prompt_for_download": False,
     }
     chrome_options.add_experimental_option("prefs", prefs)
     dr = webdriver.Chrome(options=chrome_options)
     dr.get(url_rj)
     dr.maximize_window()
     dr.find_element_by_xpath('//*[@id="pageList"]/div[9]/div[1]/a').click()
     while True:
         save_pixel = pa.locateOnScreen(save_button_path +
                                        "save_button.png")
         if save_pixel is not None:
             try:
                 x, y = pa.center(
                     pa.locateOnScreen(save_button_path +
                                       "save_button.png"))
                 click(coords=(x, y))
             except Exception as result:
                 print(result)
             break
     dr.close()
Пример #5
0
 def _get_data_from_panel(self, panel, title, refresh=False):
     result = []
     rect = panel.rectangle()
     if refresh:
         x, y = rect.right - 85, (rect.top + rect.bottom) // 2
         mouse.move(coords=(x, y))
         mouse.click(coords=(x, y))
         time.sleep(0.5)
     x, y = rect.right - 20, (rect.top + rect.bottom) // 2
     mouse.move(coords=(x, y))
     mouse.click(coords=(x, y))
     time.sleep(1.5)
     self.app.top_window().type_keys("^C", set_foreground=False)
     self.app.top_window().type_keys("%{s}%{y}", set_foreground=False)
     time.sleep(1)
     #
     try:
         file_name = pywinauto.clipboard.GetData()
         #
         data = xlrd.open_workbook('C:\\Users\\Administrator\\Desktop\\%s' %
                                   file_name,
                                   encoding_override='GBK')
         table = data.sheets()[0]
         #
         nrows = table.nrows
         for i in range(nrows):
             # print(table.row_values(i))
             result.append(table.row_values(i))
     # pylint: disable=broad-except
     except Exception as e:
         print(e)
     #
     return result
Пример #6
0
 def test_position(self):
     left, top = self.__get_pos(50)
     print(left, top)
     mouse.click(coords=(left, top))
     data = self.__get_text()
     self.assertTrue(str(int(top)) in data)
     self.assertTrue(str(int(left)) in data)
Пример #7
0
 def test_position(self):
     left, top = self.__get_pos(50)
     print(left, top)
     mouse.click(coords=(left, top))
     data = self.__get_text()
     self.assertTrue(str(int(top)) in data)
     self.assertTrue(str(int(left)) in data)
Пример #8
0
    def open_control_dialog(self, menuitems, timeout=10):
        self.spec = self.app['RS³   18483 1']
        if self.spec.exists() == False:
            print('RS3 not found. Failed to open save menu')
            return
        self.spec.set_focus()
        time.sleep(
            0.25
        )  #Not sure if this is needed. On desktop, was clicking inside pyzo sometimes.
        x_left = self.spec.rectangle().left
        y_top = self.spec.rectangle().top

        while x_left < -10 or y_top < -10:
            x_left = self.spec.rectangle().left
            y_top = self.spec.rectangle().top
            time.sleep(0.25)

        width = 300
        height = 50
        controlregion = (x_left, y_top, width, height)

        loc = None
        found = False
        for _ in range(10 * timeout):
            loc = find_image(IMG_LOC + '/rs3control.png', loc=controlregion)
            print(loc)
            if loc == None:
                print('Searching for image 2')
                loc = find_image(IMG_LOC + '/rs3control2.png',
                                 loc=controlregion)
                time.sleep(0.25)
            else:

                x = loc[0] + controlregion[0]
                y = loc[1] + controlregion[1]
                mouse.click(coords=(x, y))
                menuregion = (x, y, 100, 300)

                #Now that you've opened the menu, find the menu item.
                for _ in range(4 * timeout):
                    loc2 = find_image(menuitems[0], loc=menuregion)
                    if loc2 == None and len(menuitems) > 1:
                        loc2 = find_image(menuitems[1], loc=menuregion)
                    if loc2 != None:
                        x = loc2[0] + menuregion[0]
                        y = loc2[1] + menuregion[1]
                        mouse.click(coords=(x, y))
                        found = True
                        break
                    else:
                        print('Searching for menu item')
                        time.sleep(0.25)
                #mouse.click(coords=(self.x_left+self.control_delta_x, self.y_menu))
                # for i in range(number):
                #     keyboard.SendKeys('{DOWN}')
                # keyboard.SendKeys('{ENTER}')
                break
        if not found:
            print('Menu item not found')
            raise Exception('Menu item not found')
Пример #9
0
    def set_window_top_and_sendkey_1(self):
        '''把sh2的copy focus并sendkey'''
        while 1:
            if self.clickWindow:
                try:
                    # wd1 = Application().connect(title_re=SH2_EXCEL_NAME,timeout=1)
                    wd2 = Application().connect(title_re=SH2_COPY_TITLE_NAME,timeout=1)

                    pcp.copy(self.sh2_1_daikinou_name)
                    time.sleep(1)
                    x = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
                    y = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
                    mouse.click(button='left',coords=(x-100,y-200))
                    # wd1.top_window().set_focus()
                    time.sleep(1)
                    
                    dlg = wd2.top_window()
                    dlg.set_focus()
                    time.sleep(1)
                    dlg.Edit.set_edit_text(self.sh2_1_daikinou_name)
                    dlg.Button0.click()
                    self.clickWindow = False
                except:
                    print('[OK] Excel - 2.xlsm 窗口置顶等待中...')
            time.sleep(1)
Пример #10
0
 def reinput(self):
     reinput = self.app['[通达信网上交易][][][][国信金太阳网上交易专业版V7.18 - [行情报价-沪深A股]][Desktop]']
     reinput.set_focus()
     lab_point = reinput.child_window(title="交易密码:", auto_id="610", control_type="Text").rectangle().mid_point()
     mouse.click(coords=(lab_point.x + 100, lab_point.y))
     # 输入账号密码
     pyautogui.typewrite(str(self.pwd))
     reinput.child_window(title="确定", auto_id="442", control_type="Button").click()
Пример #11
0
    def create_ue(self):
        '''
        创建UE
        :return:
        '''
        try:
            mts_dlg = self.app['MTS']

            tree_view = mts_dlg.TreeView
            navi_tree = tree_view
            uemenu = navi_tree.get_item('\\测试管理\\UE管理')
            time.sleep(.3)
            uemenu.click(button='right')
            menu = self.app.PopupMenu
            rect = menu.rectangle()
            coord = self.get_coords(rect)
            mouse.click(button='left', coords=coord)  # 点击右键弹出的建立模拟UE
            cell_choose = self.app.Dialog
            dlg_title = cell_choose.texts()[0]

            if dlg_title != '小区选择':
                logger.error('通讯超时')
                cell_choose.Button.click()  # 点击确定
                # 弹出小区选择对话框,选择小区下拉框为空
                cell_choose = self.app.Dialog
                # 选择小区下拉框
                cbox = cell_choose.ComboBox
                item_count = cbox.item_count()
                if item_count == 0:
                    logger.error('通讯超时')
                    cell_choose.Cancel.click()  # 点击取消
                    return False
                else:
                    return True
            else:
                cell_choose.Button.click()
                time.sleep(2)
                # 小区创建create UE
                cell_create = self.app.window(class_name='#32770')
                cell_create.Button.click()
                time.sleep(2)
                uplink_pusch_test = navi_tree.get_item(
                    '\\测试管理\\RCT测试项\\上行灵敏度测试')  # 上行灵敏度测试
                uplink_pusch_test.click(button='right')
                menu = self.app.PopupMenu
                rect = menu.rectangle()
                coord = self.get_coords(rect)
                mouse.click(button='left', coords=coord)  # 点击右键弹出的创建任务
                time.sleep(1)
                task_create = self.app.Dialog  # 创建任务对话框,点击确定即可
                time.sleep(1)
                task_create.Button.click()  # 确定按钮
                time.sleep(1)
                return True
        except Exception as e:
            logger.error('error:{}'.format(e))
            raise NotImplementedError('创建UE模块失败')
Пример #12
0
 def set_message_position(self):
     x = self.message.rectangle().left
     y = self.message.rectangle().top
     if not self.flag_5g:
         mouse.scroll(coords=(x + 100, y + 70), wheel_dist=8)
         mouse.click(coords=(x + 100, y + 70))
     else:
         mouse.scroll(coords=(x + 65, y + 145), wheel_dist=8)
         mouse.scroll(coords=(x + 65, y + 145), wheel_dist=8)
         mouse.click(coords=(x + 65, y + 145))
Пример #13
0
    def _execute(self):
        track, index = self._find_focused_track_and_index()

        self.expect_true(index is not None, "A track is selected")
        # Click slightly above the track to hit any empty space
        rect = track.rectangle()
        mouse.click(button='left', coords=(rect.left + 10, rect.top - 5))
        # TODO: I need to call this twice to work, why?
        mouse.click(button='left', coords=(rect.left + 10, rect.top - 5))
        self.expect_true(not self._find_tracks()[index].has_keyboard_focus(), "Track is no longer selected")
        self.expect_true(self._find_focused_track_and_index()[0] is None, "No Track is selected")
Пример #14
0
 def test_left_click(self):
     left, top = self.__get_pos(50)
     mouse.click(coords=(left, top))
     print(left, top)
     data = self.__get_text()
     print(data)
     self.assertTrue(str(int(top)) in data)
     self.assertTrue(str(int(left)) in data)
     self.assertTrue("LeftButton" in data)
     self.assertTrue("Mouse Press" in data)
     self.assertTrue("Mouse Release" in data)
Пример #15
0
 def test_left_click(self):
     left, top = self.__get_pos(50)
     mouse.click(coords=(left, top))
     print(left, top)
     data = self.__get_text()
     print(data)
     self.assertTrue(str(int(top)) in data)
     self.assertTrue(str(int(left)) in data)
     self.assertTrue("LeftButton" in data)
     self.assertTrue("Mouse Press" in data)
     self.assertTrue("Mouse Release" in data)
Пример #16
0
 def tick_tbbler(self, cord):
     '''
     勾选误码率TBBLER[0]-[9],AVERTBBLER
     :return:
     '''
     tbbler0 = [cord[0] + 60, cord[1] + 46]
     mouse.click(button='left', coords=tbbler0)
     for i in range(10):
         tbbler = [tbbler0[0], tbbler0[1] + 18]
         mouse.click(button='left', coords=tbbler)
         tbbler0 = tbbler
Пример #17
0
 def setUp(self):
     """Start the application set some data and ensure the application is in the state we want it."""
     if sys.platform == 'win32':
         self.app = Application()
         self.app.start(_notepad_exe())
         self.dlg = self.app.UntitledNotepad
         self.ctrl = self.dlg.Edit
     else:
         self.app = subprocess.Popen("exec " + _test_app(), shell=True)
         time.sleep(0.1)
         mouse.click(coords=(300, 300))
         time.sleep(0.1)
Пример #18
0
 def click_pop_menu(self, coord):
     '''
     点击右键弹出的菜单暂停显示
     :param rect:
     :return:
     '''
     # after_coord=(coord[0]-300,coord[1]-100)  #由于右键位置在右下角,需要偏下
     after_coord = copy.deepcopy(coord)
     mouse.click(button='right', coords=after_coord)  # 右键弹出菜单
     time.sleep(.3)
     pop_coord = (after_coord[0] + 10, after_coord[1] + 5)  # 点击弹出的暂停显示
     mouse.click(button='left', coords=pop_coord)
     time.sleep(.2)
Пример #19
0
 def click_pop_clear(self, coord):
     '''
     点击右键清除选项
     :param rect:
     :return:
     '''
     # after_coord = (coord[0] - 300, coord[1] - 100)  # 由于右键位置在右下角,需要偏下
     after_coord = copy.deepcopy(coord)
     mouse.click(button='right', coords=after_coord)  # 右键弹出菜单
     time.sleep(.3)
     pop_coord = (after_coord[0] + 20, after_coord[1] + 30)  # 点击弹出的清空
     mouse.click(button='left', coords=pop_coord)
     time.sleep(.5)
 def first_button_click(self, pic_name, pic_zh_name, title_app_name):
     wc(title_app_name).activate()
     # 截屏第一页
     self.get_xiazaiqi_screen("第一页", title_name)
     time.sleep(1)
     try:
         button_down_pixel = pa.locateOnScreen(pic_name)
         x, y = pa.center(button_down_pixel)
         click(coords=(x, y))
     except:
         button_down_pixel = pa.locateOnScreen(pic_zh_name)
         x, y = pa.center(button_down_pixel)
         click(coords=(x, y))
Пример #21
0
 def click_pop_clear(self, rect):
     '''
     点击右键清除选项
     :param rect:
     :return:
     '''
     coord = self.get_coords(rect)
     after_coord = (coord[0] - 300, coord[1] - 100)  # 由于右键位置在右下角,需要偏下
     mouse.click(button='right', coords=after_coord)  # 右键弹出菜单
     time.sleep(.1)
     pop_coord = (after_coord[0] + 20, after_coord[1] + 30)  # 点击弹出的清空
     mouse.click(button='left', coords=pop_coord)
     time.sleep(.5)
Пример #22
0
 def click_pop_menu(self, rect):
     '''
     点击右键弹出的菜单暂停显示
     :param rect:
     :return:
     '''
     coord = self.get_coords(rect)
     after_coord = (coord[0] - 300, coord[1] - 100)  # 由于右键位置在右下角,需要偏下
     mouse.click(button='right', coords=after_coord)  # 右键弹出菜单
     time.sleep(.1)
     pop_coord = (after_coord[0] + 10, after_coord[1] + 5)  # 点击弹出的暂停显示
     mouse.click(button='left', coords=pop_coord)
     time.sleep(.5)
Пример #23
0
def checkIfRectangle(image, singleContour):
    #dependent on the global 'image' variable
    M = cv2.moments(singleContour)
    contourPerimeter = cv2.arcLength(singleContour, True)
    approximation = cv2.approxPolyDP(singleContour, 0.09 * contourPerimeter,
                                     True)

    if len(approximation) == 4:
        if M['m00'] > 100:
            groupX = np.sort([x[0][0] for x in approximation])
            groupY = np.sort([x[0][1] for x in approximation])

            if image[groupY[0] + 3][groupX[3] -
                                    3][0] == 112 or image[groupY[0] +
                                                          3][groupX[3] -
                                                             3][1] == 112:

                #########getting what we want
                xPosMouse = int(np.mean(groupX))
                yPosMouse = int(groupY[0] + yPosArrange *
                                (groupY[3] - groupY[0]))

                mouse.click(button='right', coords=(xPosMouse, yPosMouse))
                keyboard.send_keys('o')
                sleep(.3)

                with mss.mss() as sct:
                    img = sct.grab({
                        'top': 144,
                        'left': 14,
                        'height': 1,
                        'width': 1
                    })

                    if img.pixel(0, 0) != (236, 233, 216):
                        return False,

                    else:
                        keyboard.send_keys('{ESC}')
                        return True, (groupX[3], groupY[3]), (xPosMouse,
                                                              yPosMouse)
                        # first for checking whether it is a rectangle
                        # second for writing tag number on the taglistpicture.png
                        # third for moving mouse pointer to do the capture

            else:
                return False,
        else:
            return False,
    else:
        return False,
Пример #24
0
 def seal(self,code=None, type=None, price=None, num=None):
     right_win = self.deal_win.child_window(auto_id="59649", control_type="Pane")
     # 股东代码
     code_type_point = right_win.child_window(auto_id="12015", control_type="ComboBox").rectangle().mid_point()
     mouse.click(coords=code_type_point)
     mouse.click(coords=(code_type_point.x, code_type_point.y + 15 + type * 15))  # 15 深 30 沪
     right_win.child_window(auto_id="12006", control_type="Edit").set_text(str(price))  # 卖出价格
     right_win.child_window(auto_id="12005", control_type="Edit").set_text(str(code))  # 证券代码
     right_win.child_window(auto_id="12007", control_type="Edit").set_text(str(num))  # 数量
     time.sleep(0.3)
     right_win.child_window(title="卖出下单", auto_id="2010", control_type="Button").click()
     time.sleep(0.2)
     keyboard.send_keys('{VK_RETURN}')
     time.sleep(2)
     keyboard.send_keys('{VK_ESCAPE}')
 def install_button_click(self, pic_name, pic_zh_name, title_app_name):
     while True:
         # 激活软件窗口
         wc(title_app_name).activate()
         if pa.locateOnScreen(pic_name) is not None:
             x, y = pa.center(pa.locateOnScreen(pic_name))
             # 截屏第三页
             self.get_xiazaiqi_screen("第三页", title_name)
             click(coords=(x, y))
             break
         elif pa.locateOnScreen(pic_zh_name) is not None:
             x, y = pa.center(pa.locateOnScreen(pic_zh_name))
             # 截屏第三页
             self.get_xiazaiqi_screen("第三页", title_name)
             click(coords=(x, y))
             break
Пример #26
0
 def _login(self,login_title='国信金太阳网上交易专业版V7.18',deal_title='[国信金太阳网上交易专业版V7.18 - [行情报价-沪深A股]][Desktop]'):
     login_win = self.app[login_title]
     login_win.set_focus()
     # 获取窗口坐标,点击独立交易
     react = login_win.rectangle()
     # 点击独立交易
     mouse.click(coords=(react.left + 330 + 55, react.top + 68 + 13))
     # 输入账号密码
     # login_win.ComboBox.child_window(auto_id="1001", control_type="Edit").set_text(no)
     pyautogui.typewrite(str(self.no))
     keyboard.send_keys('{VK_TAB}')
     pyautogui.typewrite(str(self.pwd))
     keyboard.send_keys('{VK_TAB}')
     pyautogui.typewrite(str(self.dimpw))
     # 点击登录
     mouse.click(coords=(react.left + 90 + 30, react.top + 230 + 11))
     self.deal_win = self.app[deal_title]
Пример #27
0
def user_single_click(text):
    time.sleep(0.5)
    img = PIL.ImageGrab.grab()
    #imgplot = plt.imshow(img)
    data = pytesseract.image_to_data(img)

    data = data.split()
    #print(data)
    draw = ImageDraw.Draw(img)
    coords_list = []
    count = 1
    '''for i in range(len(data)):
        if ' '.join(text) in data[i].lower():
            print("Match Found")
            #coord_x = int(data[i-5]) + int(data[i-3]/2)
            #coord_y = int(data[i-4]) + int(data[i-2]/2)
            coord_x = int(data[i-5]) + int(int(data[i-3])/2)
            coord_y = int(data[i-4]) + int(int(data[i-2])/2)
            mouse.click(button="left",coords=(coord_x,coord_y))
            print("Mouse Clicked at: (" ,coord_x,",", coord_y,")")
            break'''
    for i in range(len(data)):
        if ' '.join(text) in data[i].lower():
            print("Match Found")
            coord_x = int(data[i - 5]) + int(int(data[i - 3]) / 2)
            coord_y = int(data[i - 4]) + int(int(data[i - 2]) / 2)
            draw.text((coord_x, coord_y),
                      str(count),
                      fill="rgb(240,0,0)",
                      font=font)
            coords_list.append((coord_x, coord_y))
            count += 1

    #if count>2:
    img.show()
    winsound.Beep(frequency, duration)
    #if voice_cmd:
    im_no = str(speech.press_record())
    #else:
    #   im_no = int(input("Enter The number of image to select: "))
    #  time.sleep(2)
    #print(im_no)
    SendKeys("%{F4}")
    time.sleep(1)
    mouse.click(button='left', coords=(coords_list[int(im_no) - 1]))
Пример #28
0
 def do_upload(self):
     time.sleep(5)
     # 点击上传按钮
     app = self.app
     mouse.click('left', (676, 89))
     # time.sleep(5)
     app['在线操作'].wait('ready', 10)
     dialog_online = app['在线操作']
     dialog_online['参数+程序(&P)'].Click()
     dialog_online['执行(&E)'].Click()
     app['Wecon PLC Editor'].wait('ready', 10)
     app['Wecon PLC Editor']['是(&Y)'].Click()
     app['Wecon PLC Editor'].wait('ready', 10)
     app['Wecon PLC Editor']['是(&Y)'].Click()
     app['Wecon PLC Editor'].wait('ready', 10)
     app['Wecon PLC Editor']['确定'].Click()
     dialog_online['关闭'].Click()
     print('上传成功')
Пример #29
0
 def find_sql(self, database, title, sql):
     """查询sql"""
     # print(self.app.windows())
     title = '无标题 @{} ({}) - 查询 - Navicat Premium'.format(database, title)
     find_dlg = self.app[title]
     # find_dlg['TabControl'].Pane.print_control_identifiers()
     # 获取编辑框
     edit = find_dlg['TabControl'].Pane
     # 获取编辑窗口控件位置
     rect = edit.rectangle().mid_point()
     mouse.click(coords=(rect.x, rect.y))
     k = PyKeyboard()
     # 输入sql语句
     k.type_string("{}".format(sql))
     time.sleep(1)
     # 使用ctrl+r运行语句
     mouse.click(coords=(rect.x, rect.y))
     k.press_keys([k.control_key, 'r'])
Пример #30
0
def mainWork(image, tagNumber, optionWithInfo, req, contour, tagName,
             tagNamePosition, tagDetailPosition, dummyFolderName, status,
             windows, isSimple):
    contour = contour.astype('int')
    cv2.drawContours(image, [contour], -1, (0, 255, 0), 2)
    cv2.putText(image, str(tagNumber), tagNamePosition,
                cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2)
    tagNameWithFolder = dummyFolderName + "/" + tagName
    createFolder(tagNameWithFolder)

    totalLength = len(optionWithInfo)
    keyList = list(optionWithInfo.keys())
    count = 0
    while status['isRunning'] and count < totalLength:
        if status['isPaused']:
            pass
        else:
            #windows['ab'].set_focus()
            mouse.click(button='right', coords=tagDetailPosition)
            sleep(0.5)
            keyboard.send_keys(optionWithInfo[keyList[count]][2])
            #windows['ab'].type_keys(optionWithInfo[keyList[count]][2])
            sleep(0.3)
            keyboard.send_keys('{F2 3}')
            #windows['ab'].type_keys('{F2 3}')
            sleep(0.1)
            keyboard.send_keys('{VK_SUBTRACT ' +
                               str(optionWithInfo[keyList[count]][0]) + '}')
            #windows['ab'].type_keys('{VK_SUBTRACT '+str(optionWithInfo[keyList[count]][0])+'}')
            sleep(0.2)

            with mss.mss() as sct:
                captureSave(keyList[count], tagNameWithFolder, req['endDate'],
                            optionWithInfo[keyList[count]][1], sct,
                            req['fileNamePrefix'], status, windows, isSimple)

            count += 1
            windows['ab'].set_focus()
            keyboard.send_keys('{ESC}')
            #windows['ab'].type_keys('{ESC}')
            sleep(0.3)
    #windows['ab'].type_keys('{ESC}')
    windows['ab'].set_focus()
    keyboard.send_keys('{ESC}')
Пример #31
0
def add_TCP_Case(window_name):
    app.click(window_name, u'测试用例')
    app._wait_child(window_name, u'测试用例集', 'ready', 10, 2)
    app.right_click(window_name, 'TreeView2')
    app.Sendk('DOWN', 2)
    app.Sendk('ENTER',1)
    app._wait_child(window_name, u'新建用例分类', 'ready', 10, 2)
    app.click(window_name, u'确定')
#     app._wait_not_child(window_name, u'新建用例分类', 'ready', 10, 2)
    app._wait_child(window_name, u'用例分类', 'ready', 10, 2)
    app.right_click(window_name,u'用例分类') #测试用例root
    time.sleep(1)
    app.Sendk('DOWN',4)
    app.Sendk('ENTER',1)
    app._wait_child(window_name, u'新建测试用例', 'ready', 10, 2)
    app.Sendk('TAB',2)
    app.input(window_name, 'Edit1', 'content2')#输入用例名
    app.click(window_name,u'确定') #确定
    app.click(window_name,u'用例分类')
    app.Sendk('RIGHT',1)
    app.Sendk('DOWN',1)
    app._wait_child(window_name, 'content2', 'ready', 10, 2)
    

#添加信号
    app.click(window_name, u'测试用例变量')
    app.click(window_name, 'Button16')
    app._wait_child(window_name, u'选择信号对话框', 'ready', 10, 2)
    ms.click(coords=(610,470))#复选信号
    app.click(window_name, 'Button14')#确定
    app._wait_child(window_name, u'signal', 'ready', 10, 2)


#测试用例编辑    
    app.click(window_name, u'测试用例编辑')
    app.right_click(window_name, 'TreeItem16')
    app.Sendk('UP', 1)
    app.Sendk('ENTER', 1)#快速生成
    app._wait_child(window_name, u'删除', 'ready', 10, 2)
    ms.press(button='left',coords=(600,229))
    ms.move(coords=(661, 646))
    ms.release(button='left', coords=(661, 646))
    app.click(window_name, u'确定')
    app._wait_child(window_name, u'发送[signal]', 'ready', 10, 2)
Пример #32
0
    def create_ue(self):
        '''
        创建UE
        :return:
        '''
        try:
            mts_dlg = self.app.Dialog
            tree_view = mts_dlg['SysTreeView32']
            navi_tree = tree_view.TreeItem
            ue_management = navi_tree.TreeItem1

            rect = ue_management.rectangle()
            coord = self.get_coords(rect)
            mouse.click(button='right', coords=coord)  # 右键弹出建立模拟UE
            pop_coord = (coord[0] + 5, coord[1] + 5)
            mouse.click(button='left', coords=pop_coord)
            time.sleep(1)

            cell_choose = mts_dlg.Dialog2
            dlg_title = cell_choose.texts()[0]
            if dlg_title != '小区选择':
                logger.error('通讯超时')
                cell_choose.Button.click()  # 点击确定
                # 弹出小区选择对话框,选择小区下拉框为空
                cell_choose = mts_dlg.Dialog2
                # 选择小区下拉框
                cbox = cell_choose.ComboBox
                item_count = cbox.item_count()
                if item_count == 0:
                    logger.error('通讯超时')
                    cell_choose.Cancel.click()  # 点击取消
                    return False
                else:
                    return True
            else:
                cell_choose.Button.click()
                time.sleep(1)

                cell_create = mts_dlg.Dialog2
                cell_create.Button.click()
                time.sleep(1)
                uplink_pusch_test = navi_tree.TreeItem6  # UPlink PUSCH TEST
                rect = uplink_pusch_test.rectangle()
                coord = self.get_coords(rect)
                mouse.click(button='right', coords=coord)  # 右键弹出创建任务
                pop_coord = (coord[0] + 5, coord[1] + 5)  # 点击弹出的菜单
                mouse.click(button='left', coords=pop_coord)
                time.sleep(.3)
                task_create = mts_dlg.Dialog2  # 创建任务对话框,点击确定即可
                task_create.Button2.click()
                time.sleep(3)
                return True
        except Exception as e:
            raise NotImplementedError('创建UE模块失败')
Пример #33
0
 def test_click(self):
     mouse.click(coords=(self.__get_pos(50)))
     data = self.__get_text()
     self.assertTrue("LeftButton" in data)
     self.assertTrue("Mouse Press" in data)
     self.assertTrue("Mouse Release" in data)
Пример #34
0
    def _mouse_click_and_unhook(self, coords):
        """A timer callback to perform a mouse click and unhook"""
        click(coords=coords)

        # Give a time to process the mouse clicks by the hook
        self._sleep_and_unhook()
Пример #35
0
 def setUp(self):
     """Start the application set some data and ensure the application is in the state we want it."""
     self.app = subprocess.Popen("exec " + _test_app(), shell=True)
     time.sleep(0.1)
     mouse.click(coords=(300, 300))
     time.sleep(0.1)
Пример #36
0
 def test_vertical_scroll_down(self):
     mouse.click(coords=(self.__get_pos(50)))
     mouse.scroll(self.__get_pos(50), -1)
     data = self.__get_text()
     self.assertTrue("DOWN" in data)