Ejemplo n.º 1
0
    def get_row(self):
        self.control.type_keys('^c')
        self.clipboard = clipboard.GetData()
        if self.items is not None and self.row is not None:
            for i in range(4):  # 4 attempts to read row
                if not self.get_items():
                    time.sleep(4)
                else:
                    self.control.type_keys('^c')
                    self.clipboard = clipboard.GetData()
                    break

        return self.clipboard
Ejemplo n.º 2
0
    def __get_grid_data(self):
        """ 获取grid里面的数据 """
        grid = self.main_wnd.window(control_id=0x417,
                                    class_name='CVirtualGridCtrl')

        grid.set_focus().right_click()  # 模拟右键
        #keyboard.SendKeys('c')  # 模拟发送C

        keyboard.SendKeys('{DOWN}')
        time.sleep(0.1)
        keyboard.SendKeys('{DOWN}')
        time.sleep(0.1)
        keyboard.SendKeys('{DOWN}')
        time.sleep(0.1)
        keyboard.SendKeys("{ENTER}")

        file_path = "tmp.png"
        self.app.top_window().window(control_id=0x965, class_name='Static').\
            CaptureAsImage().save(file_path)  # 保存验证码

        captcha_num = captcha_recognize(file_path)  # 识别验证码
        print("captcha result-->", captcha_num)
        self.app.top_window().window(control_id=0x964,
                                     class_name='Edit').set_text(
                                         captcha_num)  # 模拟输入验证码

        self.app.top_window().set_focus()
        keyboard.SendKeys("{ENTER}")  # 模拟发送enter,点击确定

        data = clipboard.GetData()
        df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
        return df.to_dict('records')
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def testMenuSelectNotepad_bug(self):
        """In notepad - MenuSelect Edit->Paste did not work"""
        text = b'Here are some unicode characters \xef\xfc\r\n'
        self.app2.UntitledNotepad.Edit.wait('enabled')
        time.sleep(0.3)
        self.app2.UntitledNotepad.Edit.set_edit_text(text)
        time.sleep(0.3)
        self.assertEqual(
            self.app2.UntitledNotepad.Edit.text_block().encode(
                locale.getpreferredencoding()), text)

        Timings.after_menu_wait = .7
        self.app2.UntitledNotepad.menu_select("Edit->Select All")
        time.sleep(0.3)
        self.app2.UntitledNotepad.menu_select("Edit->Copy")
        time.sleep(0.3)
        self.assertEqual(
            clipboard.GetData().encode(locale.getpreferredencoding()), text)

        self.dlg.set_focus()
        self.dlg.menu_select("Edit->Select All")
        self.dlg.menu_select("Edit->Paste")
        self.dlg.menu_select("Edit->Paste")
        self.dlg.menu_select("Edit->Paste")

        self.app2.UntitledNotepad.menu_select("File->Exit")
        self.app2.window(title='Notepad',
                         class_name='#32770')["Don't save"].click()

        self.assertEqual(
            self.dlg.Edit.text_block().encode(locale.getpreferredencoding()),
            text * 3)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def __get_grid_data(self, require_dates = False):
        """
        取得GRID窗口中的数据。
        1. require_dates = True, 有些平台有两个子窗口。一个填日期,一个显示数据。
        2. require_dates = False, 有些平台带日期,但只有一个GRID窗口。
        """
        if require_dates:
            self.main_wnd.child_window(title="Custom1", class_name='CVirtualGridCtrl', found_index=1).set_focus()  # .right_click()  # 模拟右键
        else:
            self.main_wnd.child_window(title="Custom1", class_name='CVirtualGridCtrl', found_index=0).set_focus()

        # 复制
        keyboard.send_keys('^c')  # Ctrl+C

        # 跳出验证码窗口
        self.app.top_window().wait('ready',timeout=2)

        # 验证码错误就重新输入
        trial = 1
        # 最多尝试5次识别,避免循环
        while trial <=5:
            # 识别并输入验证码,确认关闭验证码窗口
            print("最多识别5次,现在第%d次"%trial)
            self.app.top_window().child_window(class_name='Edit').set_text(self.__get_char())
            self.app.top_window().child_window(class_name='Edit').type_keys("{ENTER}")
            trial += 1
            try:
                "验证码错误" in self.app.top_window().window(class_name="Static",title="验证码错误!!").texts()
            except:
                break #验证码有错,则继续

        data = clipboard.GetData()
        df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
        return df.to_dict('records')
Ejemplo n.º 7
0
 def __get_grid_data(self, index=3):
     grid = self.main_wnd.window(control_id=0x417,
                                 class_name='CVirtualGridCtrl')
     clipboard.EmptyClipboard()
     grid.send_keystrokes('^C')
     data = clipboard.GetData()
     df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
     return df.to_dict('records')
Ejemplo n.º 8
0
def table_to_df(tree_item, table_window):
    tree_item.select()
    table_window.type_keys("^A^C")
    table_string = clipboard.GetData()
    buf = StringIO(table_string)
    df = pd.read_csv(buf, header=0, delim_whitespace=True,
                     index_col=False, dtype=str, error_bad_lines=False)
    return df
Ejemplo n.º 9
0
    def autoMemorize(self, gui):
        # クリップボードのコピー内容を消去
        clipboard.EmptyClipboard()
        # 開いているウィンドウのハンドル一覧を取得
        windowHandles = self.getWindowHandles()

        # 最前面にあるウィンドウがブラウザならURLを取得
        firstElememt = findwindows.find_element(handle=windowHandles[0])
        # Mozilla FirefoxからURL取得
        if re_search('Mozilla Firefox', str(firstElememt)) is not None:
            keyboard.send('ctrl+l,shift,ctrl+c')
        elif re_search('Google Chrome', str(firstElememt)) is not None:
            keyboard.send('ctrl+l,shift,ctrl+c')
        else:
            # 対応ブラウザでない場合は取得中止
            return
        # 0.5秒までの間にクリップボードにコピーされたら途中で抜ける
        for t in range(5):
            if clipboard.GetClipboardFormats() != []:
                break
            time_sleep(0.1)  # コピーが間に合わなければ0.1秒待つ
        # クリップボードが空なら中止(フォーマットが取得されないことで判定)
        if clipboard.GetClipboardFormats() == []:
            return
        # クリップボードにコピーしたURLを取得
        copiedURL = clipboard.GetData()
        # print(copiedURL)
        # 何もコピーされていないなら中止
        if len(copiedURL) == 0:
            return
        URL_pattern = []
        # URL文字数を30から順に区切る
        if len(copiedURL) >= 15:
            if len(copiedURL) >= 20:
                if len(copiedURL) >= 25:
                    if len(copiedURL) >= 30:
                        URL_pattern.append(copiedURL[0:30])
                    URL_pattern.append(copiedURL[0:25])
                URL_pattern.append(copiedURL[0:20])
            URL_pattern.append(copiedURL[0:15])
        else:
            URL_pattern.append(copiedURL)

        # URL文字数を30,25,20,15の順に減らしながら,含まれるアカウントを探す
        # 該当アカウントが1つだけならユーザID/Mailとパスワードを取得
        for i in range(len(URL_pattern)):
            # print(URL_pattern[i])
            IDandPass = gui.cmdEvt.autoFindByURL(URL_pattern[i])
            if IDandPass != {}:
                serviceName = IDandPass['Service']
                IDorMail = IDandPass['ID']
                passWord = IDandPass['Pass']
                # ユーザID/Mailとパスワードの一時保存
                # つまり自動memorize
                gui.cmdEvt.setMemorize(serviceName, IDorMail, passWord)
                break
Ejemplo n.º 10
0
def copy_chatroom(chatroom_name):
    hwndMain = win32gui.FindWindow(None, chatroom_name)
    hwndListControl = win32gui.FindWindowEx(hwndMain, None,
                                            "EVA_VH_ListControl_Dblclk", None)

    PostKeyEx(hwndListControl, ord('A'), [w.VK_CONTROL], False)
    time.sleep(1)
    PostKeyEx(hwndListControl, ord('C'), [w.VK_CONTROL], False)
    ctext = clipboard.GetData()
    return ctext
Ejemplo n.º 11
0
    def __get_grid_data2(self, index=3):

        grid = self.main_wnd.window(control_id=0x417,
                                    class_name='CVirtualGridCtrl')
        #time.sleep(0.1)
        grid.set_focus().right_click()  # 模拟右键
        for i in range(index):
            keyboard.send_keys('{DOWN}')
        keyboard.send_keys('{ENTER}')
        data = clipboard.GetData()
        df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
        return df.to_dict('records')
Ejemplo n.º 12
0
 def get_data_frozen(self):
     """
     获取同花顺撤单股票明细
     读取ListView中的信息
     :return: 清洗后的数据
     """
     self.copy_frozen()
     data = clipboard.GetData()
     df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
     df = pd.DataFrame(df, columns=[u'证券代码', u'证券名称', u'操作', u'委托数量'])
     df.set_index([u'证券代码'], inplace=True)
     print(df)
Ejemplo n.º 13
0
def copy_chatroom(chatroom_name):
    # # 핸들 _ 채팅방
    hwndMain = win32gui.FindWindow(None, chatroom_name)
    hwndListControl = win32gui.FindWindowEx(hwndMain, None,
                                            "EVA_VH_ListControl_Dblclk", None)

    # #조합키, 본문을 클립보드에 복사 ( ctl + c , v )
    PostKeyEx(hwndListControl, ord('A'), [w.VK_CONTROL], False)
    time.sleep(1)
    PostKeyEx(hwndListControl, ord('C'), [w.VK_CONTROL], False)
    ctext = clipboard.GetData()
    # print(ctext)
    return ctext
Ejemplo n.º 14
0
 def chang_tx_property(self, tx_type, freq, bandwidth):
     self.set_message_position()
     if self.flag_5g:
         keyboard.send_keys('{DOWN %d}' % (9 + 4 * tx_type))
     else:
         keyboard.send_keys('{DOWN %d}' % (26 + 4 * tx_type))
     self.set_text_position()
     keyboard.send_keys('^a^c')
     keyboard.send_keys('{BACKSPACE}')
     data = clipboard.GetData()
     re1 = re.compile("(?P<First><frequency>)(\d+)(?P<Second></frequency>.+?<bandwidth>)(\d+)(?P<Third></bandwidth>)", flags=re.S)
     r1 = re.sub(re1, r'\g<First>%d\g<Second>%d\g<Third>' % (freq*10e6, bandwidth*10e6), data)
     keyboard.send_keys(r1, pause=0.01, with_spaces=True, with_tabs=True, with_newlines=True)
     self.button_save.click_input()
Ejemplo n.º 15
0
 def __get_grid_data(self, is_records=True):
     """ 获取grid里面的数据 """
     self.__click_update_button()
     time.sleep(0.5)
     grid = self.main_wnd.window(control_id=0x417, class_name='CVirtualGridCtrl')
     grid.set_focus()
     time.sleep(0.5)
     pywinauto.keyboard.SendKeys('^c')
     data = clipboard.GetData()
     df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
     if is_records:
         return df.to_dict('records')
     else:
         return df
Ejemplo n.º 16
0
    def pull_out_sda_code(self):
        sda_control = self.app_sda['Steam Desktop Authenticator']
        sda_control.set_focus()
        sda_control['ListBox'].click()
        items = sda_control['ListBox'].item_texts()

        for i, item in enumerate(items):
            if item == self.steam_account.account_name:
                sda_control.set_focus()
                sda_control['ListBox'].select(i)
                sda_control['Copy'].click()
                code = clipboard.GetData()
                print('ST_CONN CODE', code)
                self.exec_steam_code(code)
                break
Ejemplo n.º 17
0
    def get_position_data(self):
        """
        #获取同花顺持仓股票明细
        读取ListView中的信息
        :return: 清洗后的数据
        """
        self.copyto()
        data1 = clipboard.GetData()

        data = data1.replace("(%)", "")
        df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
        ret = df.to_dict('records')
        for i in ret:
            i[u'证券代码'] = str(i[u'证券代码']).zfill(6)

        return ret
Ejemplo n.º 18
0
    def readchat(self):
        self._PostVirtualKey(ord('A'), [wc.VK_CONTROL])
        time.sleep(0.1)
        self._PostVirtualKey(ord('C'), [wc.VK_CONTROL])
        lc = re.split('\r|\n', clipboard.GetData())

        ret = KakaochatList()
        for line in lc:
            try:
                name = line[1:line.index(']')]
                line = line[line.index(']') + 3:]
                tm = line[:line.index(']')]
                line = line[line.index(']') + 2:]
                ret.add(Kakaochat(name, tm, line))
            except:
                pass

        return ret
Ejemplo n.º 19
0
    def __get_grid_data(self, is_records=False):
        """ 获取grid里面的数据 """
        time.sleep(API_Config.cfg["sleepC"])  # 等待1秒是 因为等待加载到数据后再去获取grid
        try:
            self.main_wnd.window(control_id=0x417,
                                 class_name='CVirtualGridCtrl').set_focus()
        except:
            time.sleep(API_Config.cfg["sleepC"])
            self.main_wnd.window(control_id=0x417,
                                 class_name='CVirtualGridCtrl').set_focus()

        keyboard.send_keys('{VK_APPS}')  # 键盘鼠标右键
        time.sleep(API_Config.cfg["sleepA"])
        keyboard.send_keys('c')  # 发送c 软件中的复制功能通过右键实现(ctrl+c快捷键不起作用)
        time.sleep(API_Config.cfg["sleepA"])
        data = clipboard.GetData()  # 读取剪贴板数据
        df = pd.read_csv(io.StringIO(data), delimiter='\t', na_filter=False)
        if is_records:
            return df.to_dict('records')
        else:
            return df
from pywinauto import clipboard
print(clipboard.GetData())
Ejemplo n.º 21
0
 time.sleep(2)
 app.top_window_().TypeKeys("{ENTER 2}")
 time.sleep(5)   
 app.top_window_().TypeKeys("{DOWN 220}{UP}")
 time.sleep(8)
 last = '1'
 url = ''
 i = 0
 while url != last:
     last = url
     app.top_window_().TypeKeys("+{F10}{DOWN 3}{ENTER}")
     time.sleep(3)
     app.top_window_().TypeKeys("{TAB 5}")
     app.top_window_().TypeKeys("^a^c")
     time.sleep(2)
     url = clipboard.GetData()
     url = url[url.find('<PageUrl>')+9:]
     url = url[:url.find('<')]
     rules_edit = data.replace('link_base', url)
     app.top_window_().TypeKeys("{TAB 4}{ENTER 2}")
     with open(os.path.join(base+'\\check.txt'), 'w',encoding='utf-8') as file_save:
         file_save.write(rules_edit)
     file_save.close()
     if 'http' in url and url != last:
         app.top_window_().TypeKeys("+{F10}{DOWN 4}{ENTER}")
         time.sleep(3)
         app.top_window_().TypeKeys("C:\\Users\\Admin\\Documents\\rule\\edit_rule\\check.txt{ENTER 2}")
         print('Done! with %s' %(i))
         time.sleep(3)
         app.top_window_().TypeKeys("{DOWN}")
         time.sleep(1)
Ejemplo n.º 22
0
app = application.Application(backend="uia").connect(
    path="C:\全能行证券交易终端\\xiadan.exe")
dlg = app['Dialog']['网上股票交易系统5.0']
# dialogs = app.windows()
# dlg.print_control_identifiers()
first_panel = dlg.child_window(auto_id="59648", ctrl_index=0)
# first_panel.print_control_identifiers()

order_history = dlg.child_window(title="历史委托")
order_history.select()
order_history.print_control_identifiers()
order_history_list = first_panel.child_window(title="Custom1",
                                              control_type="Pane")
order_history_list.type_keys("^A^C")
order_history_text = clipboard.GetData()
order_history_text
buf = StringIO(order_history_text)
buf.seek(0)
df = pd.read_csv(buf,
                 header=0,
                 delim_whitespace=True,
                 index_col=False,
                 dtype=str,
                 error_bad_lines=False)
df
is_002007 = df['证券代码'] == "002007"
is_002007
start = pd.Series([True] * 145, name='证券')
start
Ejemplo n.º 23
0
 def getHTMLWindowContent(self, htmlwindow):
     htmlwindow.TypeKeys('^A^C')
     return clipboard.GetData()
Ejemplo n.º 24
0
def getclipboard(self):
    return clipboard.GetData(format=13)
Ejemplo n.º 25
0
match = False
number_of_views_deleted = 0
for i in range(len(list_of_si_views)):
    time.sleep(0.1)
    if match:
        for downward_clicks in range(i - number_of_views_deleted):
            window.TypeKeys("{DOWN}")
            time.sleep(0.1)
    elif first_iteration:
        first_iteration = False
    else:
        window.TypeKeys("{DOWN}")
    window.TypeKeys("{TAB}")
    window.TypeKeys("^(c)")
    text = None
    text = clipboard.GetData()
    print "text " + str(i) + " =", text
    time.sleep(0.1)
    window.TypeKeys("{TAB}")
    match = False
    if text.strip() in wx_view_id_list:
        print "deleting:", text
        time.sleep(0.5)
        window.TypeKeys("{ENTER}")
        number_of_views_deleted += 1
        match = True
    for i in range(4):
        window.TypeKeys("{TAB}")
        time.sleep(0.1)

print "All done, exiting..."
Ejemplo n.º 26
0
    def process_page(self, account_name, items, lastpage_clicked_titles,
                     states, visited_urls, detail):
        clicked_titles = set()
        text = self.main_win.child_window(title=account_name,
                                          control_type="Text",
                                          found_index=0)
        parent = text
        while parent:
            parent = parent.parent()
            if '会话列表' == parent.element_info.name:
                break
        paths = [0, 2, 0, 0, 0, 1, 0]
        for idx in paths:
            parent = parent.children()[idx]

        elems = []
        self.recursive_get(parent, elems)
        win_rect = self.main_win.rectangle()
        for elem in elems:
            rect = elem.rectangle()

            if elem.element_info.name in lastpage_clicked_titles:
                continue

            if rect.top >= win_rect.bottom or rect.bottom <= self.visible_top:
                continue

            visible_height = min(rect.bottom, win_rect.bottom) - max(
                rect.top, win_rect.top + self.visible_top)
            if visible_height < 10:
                continue

            if rect.bottom - rect.top >= win_rect.bottom - self.visible_top:
                raise RuntimeError("{}-{}>={}-{}".format(
                    rect.bottom, rect.top, win_rect.bottom, self.visible_top))
            if rect.bottom >= win_rect.bottom:
                click_up = True
            else:
                click_up = False
            if self.is_bad_elem(elem):
                s = "not good elem {}".format(elem.element_info.name[0:10])
                logger.debug(s)
                WechatAutomator.add_to_detail(s, detail)
                continue

            try:
                self.click_url(rect, win_rect, click_up)
                copy_btn = self.browser.child_window(title="复制链接地址")
                self.click_center(copy_btn, click_main=False)
                url = clipboard.GetData()
                if elem.element_info.name != '图片':
                    clicked_titles.add(elem.element_info.name)
                if url and not url in visited_urls:
                    visited_urls.add(url)
                    html = None
                    try:
                        html = requests.get(url).text
                    except:
                        s = "fail get {}".format(url)
                        logger.debug(s)
                        WechatAutomator.add_to_detail(s, detail)

                    items.append((url, rect, elem.element_info.name, html))

            except:
                traceback.print_exc()
                pass
            finally:
                if self.browser:
                    try:
                        self.browser.close()
                    except:
                        pass
                    self.browser = None

            time.sleep(self.click_url_interval)

        return clicked_titles
Ejemplo n.º 27
0
 def GetClipBoard(self):
     self.currentWindow.type_keys("^a", pause=None)
     self.currentWindow.type_keys("^c", pause=None)
     return clipboard.GetData()