Example #1
0
def main():
    file_name = "history.txt"
    openfile("pynput_record", file_name)
    l1, t1 = load_replay()
    file_name = "history1.txt"
    openfile("pynput_record", file_name)
    l2, t2 = load_replay()
    file_name = "history2.txt"
    openfile("pynput_record", file_name)
    l3, t3 = load_replay()
    # print("Ready, press '.' to start")
    # keyboard.wait(".")
    play(l1, 1, t1, True)
    play(l2, 1, t2, True)
    play(l3, 1, t3, True)
    autoit.mouse_wheel("down", 30)
    autoit.mouse_click_drag(950, 470, 950, 475, button="right", speed=100)
    autoit.mouse_click_drag(950, 475, 965, 475, button="right", speed=50)
Example #2
0
def main(id, stop):
    global hook, fish, attempt, delay, log, t_last, r_spd

    while True:
        for _ in range(30):
            autoit.mouse_wheel("up", 1)
        replay.main()
        # First hook throwing
        x, y = (965, 475)
        bagsize = 300 - 3

        time.sleep(delay)
        throw_hook(x, y)
        w_timer = time.time()
        while bagsize > 0:
            capture_image()
            if not fish:
                wait_for_fish()
                if time.time() - w_timer > 10:
                    if time.time() - w_timer > 60:
                        break
                    throw_hook(965, 475)  # 1580, 660
            if fish:
                catching_fish()
                if image.getpixel(
                    (1092, 758)) != (95, 255, 93) and attempt:  # 1585, 1015
                    # # OCR function to check inventory, not workable with current version
                    # if check_inventory():
                    #     stop = True
                    #     break
                    time.sleep(delay)
                    throw_hook(965, 475)  # *x y
                    fish = False
                    bagsize -= 1
                    w_timer = time.time()
                    continue
            if stop():
                break
        if stop():
            break
    print("Core program halted")
Example #3
0
    def creat_contract_management(self):
        # 新增合同

        if WinControl(self.IMWin).exists():
            m1 = MouseControl()
            m1.click(self.IMWin, '', screen_point.选择项目部[0],
                     screen_point.选择项目部[1])
            sleep(1)
            m1.click(self.IMWin, '', screen_point.工程管理[0],
                     screen_point.工程管理[1])
            m1.click(self.IMWin, '', screen_point.合同管理[0],
                     screen_point.合同管理[1])
            m1.click(self.IMWin, '', screen_point.新增施工合同[0],
                     screen_point.新增施工合同[1])
            sleep(5)
            m1.click(self.IMWin, '', screen_point.合同编号[0],
                     screen_point.合同编号[1])
            autoit.send(self.message1)
            m1.click(self.IMWin, '', screen_point.合同金额[0],
                     screen_point.合同金额[1])
            autoit.send(self.message2)
            m1.click(self.IMWin, '', screen_point.合同签订日期[0],
                     screen_point.合同签订日期[1])
            m1.click(self.IMWin, '', screen_point.今天签订[0],
                     screen_point.今天签订[1])
            m1.click(self.IMWin, '', screen_point.建设单位[0],
                     screen_point.建设单位[1])
            autoit.send(self.message3)
            m1.click(self.IMWin, '', screen_point.施工单位[0],
                     screen_point.施工单位[1])
            autoit.send(self.message4)
            m1.click(self.IMWin, '', screen_point.起止桩号[0],
                     screen_point.起止桩号[1])
            autoit.send(self.message5)
            m1.click(self.IMWin, '', screen_point.合同段长度[0],
                     screen_point.合同段长度[1])
            autoit.send(self.message6)
            m1.click(self.IMWin, '', screen_point.计划开工日期[0],
                     screen_point.计划开工日期[1])
            m1.click(self.IMWin, '', screen_point.今天开工[0],
                     screen_point.今天开工[1])
            m1.click(self.IMWin, '', screen_point.标段号[0], screen_point.标段号[1])
            autoit.send(self.message7)
            m1.click(self.IMWin, '', screen_point.项目名称[0],
                     screen_point.项目名称[1])
            autoit.send(self.message8)
            m1.click(self.IMWin, '', screen_point.监理名称[0],
                     screen_point.监理名称[1])
            autoit.send(self.message9)
            m1.click(self.IMWin, '', screen_point.结束桩号[0],
                     screen_point.结束桩号[1])
            autoit.send(self.message10)
            m1.click(self.IMWin, '', screen_point.计划完工日期[0],
                     screen_point.计划完工日期[1])
            m1.click(self.IMWin, '', screen_point.今天完工[0],
                     screen_point.今天完工[1])
            m1.move(self.IMWin, '', 960, 590)
            autoit.mouse_wheel('down', 2)
            m1.click(self.IMWin, '', screen_point.工期[0], screen_point.工期[1])
            autoit.send(self.message11)
            m1.click(self.IMWin, '', screen_point.保存[0], screen_point.保存[1])
        else:
            raise Exception('没有检测到IM窗口!')
Example #4
0
 def wheel(self, direction="up"):
     '''
     :description 产生向上或向下滚动鼠标滚轮事件.仅支持NT/2000/XP及更高.
     '''
     autoit.mouse_wheel(direction)
Example #5
0
	def wheel(self, direction="up"):
		"""鼠标滚轮"""
		autoit.mouse_wheel(direction)
Example #6
0
def play(log, speed, tlast, debug_mode):
    st = 0.0
    stt = 0.0
    tlast -= 0.01

    if debug_mode:
        timer = time.perf_counter()
    offset_timer = time.perf_counter()

    for step in log:
        if step[0] == 'mousemove':
            t_offset = time.perf_counter() - offset_timer - st
            # print(t_offset)
            st = (float(step[-1]) - tlast - t_offset) / speed
            # print(st)
            offset_timer = time.perf_counter()
            if st > 0:
                time.sleep(st)
            stt += t_offset
            autoit.mouse_move(int(step[1]), int(step[2]), 0)
            tlast = float(step[-1])
            continue

        if step[0] == 'mousepressed':
            t_offset = time.perf_counter() - offset_timer - st
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st < 0.0:
                time.sleep(st)
            stt += t_offset
            autoit.mouse_move(int(step[2]), int(step[3]), 0)
            autoit.mouse_down(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'mousereleased':
            t_offset = time.perf_counter() - offset_timer - st
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st < 0.0:
                time.sleep(st)
            stt += t_offset
            autoit.mouse_move(int(step[2]), int(step[3]), 0)
            autoit.mouse_up(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'mousescrolled':
            t_offset = time.perf_counter() - offset_timer - st
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st > 0:
                time.sleep(st)
            stt += t_offset
            autoit.mouse_wheel(int(step[2]), int(step[3]), 0)
            autoit.mouse_up(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'keypressed':
            t_offset = time.perf_counter() - offset_timer - st
            # print(t_offset)
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st > 0:
                time.sleep(st)
            stt += t_offset
            autoit.send(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'keyreleased':
            t_offset = time.perf_counter() - offset_timer - st
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st > 0:
                time.sleep(st)
            stt += t_offset
            autoit.send(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'done':
            print('End playing')
            if debug_mode:
                print(time.perf_counter() - timer)
                print(stt)
            pass
 def wheel(cls, direction="up"):
     """
     :description 执行鼠标滚轮向上或向下滚动事件
     :return:
     """
     autoit.mouse_wheel(direction)
Example #8
0
def add_household(household):
    print('>>> Starting entry for %s' % str(household))

    autoit.win_activate("Link2Feed Portal - Google Chrome")
    time.sleep(DEFAULT_TIME)

    prime = household.primary
    second = household.secondary

    autoit.mouse_click("left", 2281, 328)
    time.sleep(1.0)
    autoit.send('{TAB}')
    autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}')
    time.sleep(DEFAULT_TIME)
    autoit.send('{ENTER}')
    autoit.send('{TAB}')
    time.sleep(DEFAULT_TIME)
    if prime.last_visit:
        visit_date = datetime.strptime(
            prime.last_visit.replace('00:00:00',
                                     '').replace('MST', '').replace('MDT', ''),
            "%a %b %d %Y")
        autoit.send(visit_date.strftime(DATE_FORMAT))
    else:
        autoit.send(prime.creation_date.strftime(DATE_FORMAT))
    autoit.send('{TAB}{UP}{TAB}')

    autoit.send(prime.last_name.upper())
    autoit.send('{TAB}')
    autoit.send(prime.first_name.upper())
    autoit.send('{TAB}')

    time.sleep(DEFAULT_TIME)
    autoit.send(prime.birthdate.strftime(DATE_FORMAT))
    time.sleep(DEFAULT_TIME)
    autoit.send('{TAB}')

    time.sleep(1.0)
    if hex(autoit.pixel_get_color(2877, 223)) == '0xf4b04f':
        write_duplicate(prime.first_name, prime.last_name, prime.birthdate)
        print('duplicate detected: %s' % str(prime))
        autoit.mouse_click("left", 3816, 15)
        time.sleep(4.0)
        autoit.send('{ENTER}')
        time.sleep(4.0)
        autoit.send('#3')
        time.sleep(10.0)
        autoit.mouse_click("left", 2246, 54)
        autoit.send('https://portal.link2feed.ca/org/2191/intake/')
        time.sleep(DEFAULT_TIME)
        autoit.send('{ENTER}')
        time.sleep(6.0)
        return

    autoit.send('{TAB}')

    if prime.gender == "female":
        autoit.send('{DOWN}')
    elif prime.gender == "male":
        autoit.send('{DOWN}{DOWN}')
    else:
        autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}')
    time.sleep(DEFAULT_TIME)
    autoit.send('{ENTER}')

    if not second:
        autoit.mouse_click("left", 2206, 807)
    elif household.relationship == 'commonlaw':
        autoit.mouse_click("left", 2474, 808)
    elif household.relationship == 'spouse':
        autoit.mouse_click("left", 2207, 831)
    else:
        autoit.mouse_click("left", 3011, 807)
    time.sleep(DEFAULT_TIME)

    autoit.mouse_move(3832, 317, 0)
    time.sleep(DEFAULT_TIME)
    autoit.mouse_down("left")
    autoit.mouse_move(3832, 716)
    autoit.mouse_up("left")

    autoit.mouse_click("left", 2206, 171)
    autoit.mouse_click("left", 2922, 224)
    autoit.mouse_click("left", 3011, 680)
    click_point_from_city(prime.city)

    if prime.income == "Student Scholarship":
        autoit.mouse_click("left", 2207, 915)
    else:
        autoit.mouse_click("left", 2205, 964)

    if prime.phone:
        fixed_phone = prime.phone.replace('(',
                                          '').replace(')',
                                                      '').replace('-', '')
        if len(fixed_phone) == 10:
            autoit.mouse_click("left", 2245, 486)
            time.sleep(DEFAULT_TIME)
            autoit.send(fixed_phone)

    autoit.mouse_wheel("down", 20)
    time.sleep(DEFAULT_TIME)

    member_count = 0
    if household.secondary:
        member_count += 1
        success = add_member(household.secondary, household.relationship, 1)
        if not success:
            return

    # for child in household.children:
    #     member_count += 1
    #     success = add_member(child, 'child', member_count)
    #     if not success:
    #         return

    autoit.mouse_click("left", 3726, 966)
    time.sleep(3.0)
    autoit.mouse_click("left", 2248, 547)
    time.sleep(DEFAULT_TIME)
    autoit.send('+{TAB}')
    time.sleep(DEFAULT_TIME)
    down_count = 1
    if not prime.income:
        down_count = 5
    elif prime.income == 'Child Benefits':
        down_count = 2
    elif prime.income == 'Disability / PWD':
        down_count = 3
    elif prime.income == 'Employment Insurance':
        down_count = 4
    elif prime.income == 'OAP / CPP':
        down_count = 6
    elif prime.income == 'Social Assistance':
        down_count = 8
    elif prime.income == 'Student Scholarship':
        down_count = 10
    elif prime.income == 'Works Casual':
        down_count = 11
    elif prime.income == 'Works Full-Time':
        down_count = 12
    else:
        down_count = 13

    for i in range(down_count):
        autoit.send('{DOWN}')

    autoit.send('{ENTER}')

    time.sleep(DEFAULT_TIME)

    autoit.mouse_click("left", 2246, 535)

    if not household.secondary:
        autoit.mouse_click("left", 3737, 736)
    else:
        autoit.mouse_click("left", 3738, 871)

    time.sleep(1.5)
    autoit.mouse_click("left", 3747, 769)
    time.sleep(1.5)
    autoit.mouse_click("left", 2762, 193)
    time.sleep(1.5)
    autoit.mouse_click("left", 3765, 353)
    time.sleep(DEFAULT_TIME)

    if prime.dietary:
        prime.dietary = prime.dietary.replace('+',
                                              '').replace('^', '').replace(
                                                  '!', '').replace('#', '')
        autoit.send('--DIET--{ENTER}')
        autoit.send(prime.dietary.replace('\n', '{ENTER}'))
        autoit.send('--DIET--{ENTER}')
    if prime.notes:
        prime.notes = prime.notes.replace('+', '').replace('^', '').replace(
            '!', '').replace('#', '')
        autoit.send(prime.notes.replace('\n', '{ENTER}'))
        if household.children:
            autoit.send('Children: %s {ENTER}' %
                        [child.age for child in household.children])
    if prime.comments:
        prime.comments = prime.comments.replace('+',
                                                '').replace('^', '').replace(
                                                    '!', '').replace('#', '')
        autoit.send(prime.comments.replace('\n', '{ENTER}'))

    autoit.mouse_click("left", 3113, 487)
    time.sleep(1.5)

    # Check for green services in case something went wrong
    if hex(autoit.pixel_get_color(2611, 192)) != '0x43a543':
        print('>>> Entry failed: green services check: %s' %
              hex(autoit.pixel_get_color(2611, 192)))
        exit(1)

    autoit.mouse_click("left", 2462, 49)
    time.sleep(DEFAULT_TIME)
    autoit.send('https://portal.link2feed.ca/org/2191/intake/')
    autoit.send('{ENTER}')

    print(">>> Finished entry for %s" % str(household))
def play(log, speed, tlast, debug_mode):
    print("Ready, press 'alt + .' to start")
    keyboard.wait("alt+.")
    if debug_mode:
        timer = time.time()
    t_offset = time.time()
    tlast -= 0.1
    for step in log:
        if step[0] == 'mousemove':
            t_offset = time.time() - t_offset
            # print(t_offset)
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.mouse_move(int(step[1]), int(step[2]), 0)
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'mousepressed':
            t_offset = time.time() - t_offset
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.mouse_move(int(step[2]), int(step[3]), 0)
            autoit.mouse_down(step[1])
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'mousereleased':
            t_offset = time.time() - t_offset
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.mouse_move(int(step[2]), int(step[3]), 0)
            autoit.mouse_up(step[1])
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'mousescrolled':
            t_offset = time.time() - t_offset
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.mouse_wheel(int(step[2]), int(step[3]), 0)
            autoit.mouse_up(step[1])
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'keypressed':
            t_offset = time.time() - t_offset
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.send(step[1])
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'keyreleased':
            t_offset = time.time() - t_offset
            time.sleep((float(step[-1]) - tlast - t_offset) / speed)
            autoit.send(step[1])
            tlast = float(step[-1])
            t_offset = time.time()
            continue

        if step[0] == 'done':
            print('Lobby settings are all set')
            if debug_mode:
                print(time.time() - timer)
            pass