Esempio n. 1
0
def move_to_move(win_title="", x=0, y=0, str_xy="", waitfor=WAIT_FOR_IMG):
    __logger.debug(u"Ready to execute[move_to_move]")

    try:
        ''''如果指定窗口'''
        if win_title != None and win_title.strip() != '':
            ''''如果窗口不活跃状态'''
            if not iwin.do_win_is_active(win_title):
                iwin.do_win_activate(win_title=win_title, waitfor=waitfor)

        msg = move_to_move_pack_au3(x, y, str_xy)

        tmp_au3_file_path = nit.gen_au3_file(msg)

        print(tmp_au3_file_path)

        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        nit.cleanup(tmp_au3_file_path)
        if status:
            '''程序执行错误'''
            __logger.error("aitprogram execution error")
            return False

        elif str(nit.get_cmd_message(stdout_string)) == "NO":
            '''autoit 执行返回结果为未找到'''
            __logger.error("move failure")
            return False
        return True
    except Exception as e:
        print(str(e), traceback.format_exc())
    finally:
        __logger.debug(u"end execute[move_to_move]")
Esempio n. 2
0
def img_exists_au3(win_title=None,
                   img_res_path=None,
                   image=None,
                   waitfor=WAIT_FOR_IMG):

    __logger.debug(u"Ready to execute[img_exists]")
    is_exists = False

    try:
        ''''如果指定窗口'''
        if win_title != None and win_title.strip() != '':
            ''''如果窗口不活跃状态'''
            if not iwin.do_win_is_active(win_title):
                iwin.do_win_activate(win_title=win_title, waitfor=waitfor)

        msg = get_img_exist_au3(img_res_path, image, waitfor)

        tmp_au3_file_path = nit.gen_au3_file(msg)

        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        nit.cleanup(tmp_au3_file_path)
        if status:
            '''program execution error'''
            __logger.error("aitprogram execution error")
            return False
        elif str(nit.get_cmd_message(stdout_string)) == "NO":
            '''autoit 执行返回结果为未找到'''
            __logger.error("ImageSearch image not found")
            return False

        return True
    except Exception as e:
        print(str(e), traceback.format_exc())
    finally:
        __logger.debug(u"au3end execute[img_exists]" + str(is_exists))
Esempio n. 3
0
def input_box(text='请输入',
              default='',
              password='',
              width=0,
              height=150,
              timeout=0):
    '''
    text:输入提示语
    default:默认值
    password:密码替代符
    width:宽
    height:高
    timeout:超时
    '''
    __logger.echo_msg(u"Ready to execute[input_box]")
    title = '输入框',
    left = 'Default'
    top = 'Default',
    au3_content = ibox_pack_au3(title, text, default, password, width, height,
                                left, top, timeout)  ##组装生成au3所需的数据,组装au3文件内容
    try:
        tmp_au3_file_path = nit.gen_au3_file(au3_content)  # 生成XXX.au3文件并返回路径
        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        if status:
            '''程序执行错误'''
            raise Au3ExecError('input_box excute fail')
        time.sleep(2)
        result = str(nit.get_cmd_message(stdout_string))

    except Exception as e:
        raise e
    finally:
        nit.cleanup(tmp_au3_file_path)
        __logger.echo_msg(u"End operation")
        return result
Esempio n. 4
0
def do_win_list():
    __logger.debug('win_title_list')
    try:
        msg = pack_au3_data()  ##组装生成au3所需的数据
        tmp_au3_file_path = nit.gen_au3_file(msg)  # 生成XXX.au3文件并返回路径
        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        nit.cleanup(tmp_au3_file_path)
        plist = str(get_win_list_string(stdout_string))
        return plist
    except Exception as e:
        raise e
Esempio n. 5
0
def img_click_au3(win_title=None,
                  img_res_path=None,
                  image=None,
                  mouse_button="left",
                  pos_curson="Center",
                  pos_offsetY=0,
                  pos_offsetX=0,
                  times=1,
                  image_size=None,
                  waitfor=WAIT_FOR_IMG):
    __logger.debug(u"Ready to execute[img_click]")

    try:
        '''如果屏幕缩放比例不是100%'''
        if not __check_scale():
            __logger.warning(
                u"Waring:The current screen zoom ratio is not 100%. Picture lookup may not be accurate."
            )
        ''''如果指定窗口'''
        if win_title != None and win_title.strip() != '':
            ''''如果窗口不活跃状态'''
            if not iwin.do_win_is_active(win_title):
                iwin.do_win_activate(win_title=win_title, waitfor=waitfor)

        msg = get_img_cli_au3(img_res_path, image, mouse_button, pos_curson,
                              pos_offsetY, pos_offsetX, image_size, waitfor,
                              times, 1)

        tmp_au3_file_path = nit.gen_au3_file(msg)

        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        nit.cleanup(tmp_au3_file_path)
        if status:
            '''程序执行错误'''
            __logger.error("Au3program execution error")
            return False
        elif str(nit.get_cmd_message(stdout_string)) == "NO":
            '''autoit 执行返回结果为未找到'''
            __logger.error("ImageSearch image not found")
            return False
        return True
    except Exception as e:
        print(str(e), traceback.format_exc())
        return False
    finally:
        __logger.debug(u"end execute[img_click]")
Esempio n. 6
0
def msg_box(title="INFO", msg="", timeout=0):
    '''
    title:标题
    msg:内容
    timeout:超时    
    '''
    __logger.echo_msg(u"Ready to execute[msg_box]")
    box_mode = 0
    au3_content = msgbox_pack_au3(box_mode, title, msg,
                                  timeout)  ##组装生成au3所需的数据,组装au3文件内容
    try:
        tmp_au3_file_path = nit.gen_au3_file(au3_content)  # 生成XXX.au3文件并返回路径
        status, error_string, stdout_string = nit.run_autoit(tmp_au3_file_path)
        if status:
            '''程序执行错误'''
            raise Au3ExecError('msg_box excute fail')
        return True
    except Exception as e:
        raise e
    finally:
        nit.cleanup(tmp_au3_file_path)
        __logger.echo_msg(u"End operation")