WindowFinder.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:myautotest 作者: auuppp 项目源码 文件源码
def expect_the_specific_dialog(self, _current_dialog):
        '''
        Set the windows white list,
        Then find another 
        :_current_dialog: 
        :return: the new top dialog
        '''
        def _expect_window_dialog_enum_callback(hwnd, extra):
            '''Call back func which checks each open window and matches the name of window using reg ex'''
            #self._handle = None
            matchtext = extra 
            logging.debug("call _window_enum_dialog_callback")
            classname = win32gui.GetClassName(hwnd)
            title_text = win32gui.GetWindowText(hwnd)
            title_text = title_text.decode('gbk').encode('utf-8')
            if classname == '#32770':
                matchtext = matchtext.encode('utf-8')
                logging.debug("msg: " + matchtext)
                logging.debug("Title is: " + title_text)

            if (matchtext.strip() == title_text.strip()):
                logging.debug("!!!!Second window BINGO!!!!")
                if hwnd not in self.white_windows_list:
                    logging.debug("Find the second window at the top")
                    self.expect_sec_window = hwnd
                    return False
                else:
                    logging.debug("Find the window at the top which is not the second")
                    return True
            else:
                logging.debug("No matched .....")
                return True

        self.white_windows_list = [_current_dialog, ]
        windowtitle = win32gui.GetWindowText(_current_dialog)
        logging.debug("To find the second window, need match " + windowtitle)

        try:
            #win32gui.EnumWindows(_expect_window_dialog_enum_callback, windowtitle)
            win32gui.EnumChildWindows(self.hwnd, _expect_window_dialog_enum_callback, windowtitle)
        except:
            logging.debug("Got the error:")
            logging.debug("win32gui.EnumWindows with " + str(_expect_window_dialog_enum_callback))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号