def checkActivatedHeroBtn(): y = hero_btn_activated_check_y # while y < 590: while y < herotap_bottombtn_y: y += 20 color = autoit.pixel_get_color(hero_btn_x, y) # skip in case not activated if color > 0xe00000: return True return False
def check_hp(percent_hp, health_info): start_bar_x, start_bar_y = health_info[0:2] start_bar_x = int(start_bar_x + 4) start_bar_y = int(start_bar_y + 20) heal = autoit.pixel_get_color( int(start_bar_x + (int(percent_hp) / 100 * 181)), start_bar_y) # print(f'Heal percent:{percent_hp}, heal color: {heal}') time.sleep(random.uniform(0.2, 0.3)) if heal != 4521796: pyautogui.press('f3') return 'Heal me!' else: return 'I\'m fine..'
def helmFindPatterntest(): # 32, 303 - 008BA3 x = 32 y = 303 c = 0x008ba3 print(f' Defie ', {x}, {y}, {hex(c)}) autoP = autoit.pixel_get_color(x, y) print(f' auto.it ', {x}, {y}, {hex(autoP)}) # found = IsColorInRect(x, y, pixels[i], xrange=1, yrange=1, step=1) found = IsColorAtCoord(x, y, c, offset=0x0) print(f'found pixel x y on p, equip p ', {found}, {x}, {y})
def check_if_at_leave_screen(): hits = 0 for x in range(top_left_scan_box_x, top_left_scan_box_x + scan_width, 10): for y in range(top_left_scan_box_y, top_left_scan_box_y - scan_height, -10): pixel = hex(autoit.pixel_get_color(x, y)) if pixel and pixel != hex(0): pixel_r, pixel_g, pixel_b = int(pixel[2:4], 16), int(pixel[4:6], 16), int(pixel[6:8], 16) # skip 0x in front pixel_r_in_tolerance = red * 0.9 < pixel_r < red * 1.1 pixel_g_in_tolerance = green * 0.9 < pixel_g < green * 1.1 pixel_b_in_tolerance = blue * 0.9 < pixel_b < blue * 1.1 if pixel_r_in_tolerance and pixel_g_in_tolerance and pixel_b_in_tolerance: hits += 1 return hits > 10
def IsOneColorAtCoord(x, y, one_color, offset=0xf): color = autoit.pixel_get_color(x, y) r = color >> 16 & 0xff g = color >> 8 & 0xff b = color & 0xff # check comparing one color cr = one_color >> 16 & 0xff cg = one_color >> 8 & 0xff cb = one_color & 0xff pc = r if cr != 0x00 else (g if cg != 0x00 else b) oc = cr if cr != 0x00 else (cg if cg != 0x00 else cb) return True if oc - offset <= pc <= oc + offset else False
def check_mana(percent_mana, health_info, title='None'): start_bar_x, start_bar_y = health_info[0:2] start_bar_x = int(start_bar_x + 4) start_bar_y = int(start_bar_y + 38) mana = autoit.pixel_get_color( int(start_bar_x + (int(percent_mana) / 100 * 181)), start_bar_y) # print(f'Mana percent:{percent_mana}, mana color: {mana}') if title == 'senzu': if mana != 4474111: pyautogui.press('f11') time.sleep(random.uniform(2.0, 2.1)) else: if mana == 4474111: pyautogui.press('f12') time.sleep(random.uniform(0.4, 0.5))
def IsColorAtCoord(x, y, check_color, offset=0x0f): color = autoit.pixel_get_color(x, y) # print(f' color at ', {x}, {y}, {hex(color)}) r = color >> 16 & 0xff g = color >> 8 & 0xff b = color & 0xff cr = check_color >> 16 & 0xff cg = check_color >> 8 & 0xff cb = check_color & 0xff if cr-offset <= r <= cr+offset and \ cg-offset <= g <= cg+offset and \ cb-offset <= b <= cb+offset: return True return False
def checkSkillStatus(at, state='ready'): x = skill_coord[at] if state == 'ready': y = skill_btn_ready_y state_color = 0xffffff elif state == 'empty': y = 970 state_color = 0xDB6700 # FS # state_color = 0x16E2E6 # HS else: # active y = skill_btn_active_y state_color = 0xffae00 for i in range(4): color = autoit.pixel_get_color(x, y + i) if color == state_color: return True return False
def changeSlash(type=SlashType.SCPorter): print(f' change changeSlash get he type ', {type}) # # move to helmet equip tap openBMenu(Icons.BMenu_Equip.name) # select slash tap if 0x424044 != autoit.pixel_get_color(355, 166): autoit.mouse_click('left', 355, 135, 1, 3) time.sleep(0.3) row = getRowOfEquipmentPattern(tap='slash', kind=type) print(f' Found slash type at row ', {type}, {row}) # equip cur type equipment if row < 0: # not found return False equiping(row) bottomMenuExit() return True
def add_member(member, relationship, count): y = 864 - 32 * count autoit.mouse_click("left", 3732, y) time.sleep(3.0) autoit.mouse_click("left", 2475, 239) time.sleep(DEFAULT_TIME) autoit.send(member.last_name.upper()) autoit.send('{TAB}') autoit.send(member.first_name.upper()) autoit.send('{TAB}') time.sleep(DEFAULT_TIME) autoit.send(member.birthdate.strftime(DATE_FORMAT)) autoit.send("{TAB}") time.sleep(3.0) if hex(autoit.pixel_get_color(2877, 223)) == '0xf4b04f': write_duplicate(member.first_name, member.last_name, member.birthdate) print('member duplicate detected: %s' % str(member)) 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 False autoit.mouse_click("left", 2567, 312) autoit.send('{TAB}') if member.gender == "female": autoit.send('{DOWN}') elif member.gender == "male": autoit.send('{DOWN}{DOWN}') else: autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') autoit.send('{TAB}') autoit.send('{DOWN}') time.sleep(DEFAULT_TIME) if relationship == 'spouse': autoit.send('{DOWN}') elif relationship == 'child': autoit.send('{DOWN}{DOWN}') else: for i in range(9): autoit.send('{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') if relationship == 'child': autoit.mouse_click("left", 2450, 350) time.sleep(DEFAULT_TIME) autoit.mouse_click("left", 2669, 423) time.sleep(DEFAULT_TIME) click_point_from_city_member(member.city) time.sleep(DEFAULT_TIME) if member.birthdate.year >= 2002: autoit.mouse_click("left", 3231, 754) else: autoit.mouse_click("left", 2449, 720) time.sleep(DEFAULT_TIME) autoit.mouse_click("left", 3231, 867) time.sleep(3.0) return True
def heroLeveling(): global hero_type print(f'Hero lv up') checkHelmetFlag = False # open bottom menu bottomMenuExit() # openBMenu(Icons.BMenu_Heroes.name) # check activated btn # 480 - 210 / 5 : - distance due to addition first in the loop if not checkActivatedHeroBtn(): bottomMenuExit() return # check if scrool is necessary # 129, 192 ~ 232 need_scroll = False for hy in range(192, 232, 5): if not IsColorAtCoord(129, 192, 0x303030, offset=0x01): need_scroll = True # scroll up if need_scroll: menuScrollUp() if checkNewlyActivatedHero(): checkHelmetFlag = True # get highest hero type hero_type = getHeroType() # click lv up btn distance_btn_y = 87 y_step = 20 number_rows = 9 # 480 - 210 / 5 : - distance due to addition first in the loop # total 3 times repeat to lve up all for n in range(2): y = hero_btn_init_y - distance_btn_y for i in range(y, y + (number_rows * distance_btn_y), y_step): y += y_step color = autoit.pixel_get_color(hero_btn_x, y) # skip in case not activated if color < 0xe00000: continue # for j in range(4): # click here again when enable btn is still on autoit.mouse_click('left', hero_btn_x, y, 1, 2) # time.sleep(0.1) # # click lv up btn # distance_btn_y = 87 # # 480 - 210 / 5 : - distance due to addition first in the loop # y = hero_btn_init_y - distance_btn_y # for i in range(9): # y += distance_btn_y # color = autoit.pixel_get_color(hero_btn_x, y) # # skip in case not activated # if color < 0xe00000: # continue # # for j in range(4): # autoit.mouse_click('left', hero_btn_x, y, 1, 3) # time.sleep(0.1) # helmet change when there is a newly activated hero # if checkHelmetFlag: # changeHelmet('force', hero_type) bottomMenuExit()
def tapFairyCollect(): # collect check 500, 774, 0x289fcb cx, cy = click_coord_table['fairycollect'] color = autoit.pixel_get_color(cx, cy) if 0x280000 < color and color < 0x28ffff: _tap('fairycollect')
def emptySkillCircle(): color = autoit.pixel_get_color(skill_coord['FS'], 970) return color != 0xDB6700
def changeHelmet(mode='stucked', hero_type=HeroEleType.Error): global _b_changing if 'stucked' == mode and _b_changing == False: return # get highest hero type # coord 368,281 +- 4, 6 # Spell: CR 0x00b1CA # melee: CR 0xfb8649 # Range: 0x6bBD42 print(f' change helmet get he type ', {hero_type}) # # move to helmet equip tap openBMenu(Icons.BMenu_Equip.name) # select helm tap if 0x424044 != autoit.pixel_get_color(126, 166): autoit.mouse_click('left', 136, 135, 1, 3) time.sleep(0.3) # row = getRowOfEquipment(tap='helm', kind=hero_type) row = getRowOfEquipmentPattern(tap='helm', kind=hero_type) print(f' Found Hero type at row ', {hero_type}, {row}) # equip cur type equipment if row < 0: # not found return False # # y step 91 interval : 10 # y = 0 # #test # helm_type_checksum = autoit.pixel_checksum(14, 381, 14+63, 381 + 63) # print(f'helm checksum y3: ', {y}, {hex(helm_type_checksum)}) # # helm_type_checksum = autoit.pixel_checksum(14, 564, 14+63, 564 + 63) # print(f'helm checksum 5: ', {y}, {hex(helm_type_checksum)}) # # helm_type_checksum = autoit.pixel_checksum(14, 655, 14+63, 655 + 63) # print(f'helm checksum 666: ', {y}, {hex(helm_type_checksum)}) # # helm_type_checksum = autoit.pixel_checksum(14, 746, 14+63, 746 + 63) # print(f'helm checksum 777: ', {y}, {hex(helm_type_checksum)}) # for y in range(Equip_Icon_y, 857, 91): # helm_type_checksum = autoit.pixel_checksum(Equip_Icon_x, y, Equip_Icon_x2, y+Equip_Icon_h) # print(f'helm checksum y: ', {y}, {hex(helm_type_checksum)}) # time.sleep(0.5) # autoit.mouse_move(Equip_Icon_x, y) # helm_type_checksum = 0 # find specific colors for the item # Helm of Tears 0x005b7d , # # if hero_type == HeroEleType.Melee: # row = Equip_Ele_Melee_y # elif hero_type == HeroEleType.Range: # row = Equip_Ele_Range_y # elif hero_type == HeroEleType.Spell: # row = Equip_Ele_Spell_y # else: # row = -2 # exit btn y offset equiping(row) bottomMenuExit() time.sleep(1) # clear trigger flag _b_changing = False return True
def add_member(member, relationship, count): y = 864 - 32 * count autoit.mouse_click("left", 3732, y) time.sleep(2.0) autoit.mouse_click("left", 2475, 239) time.sleep(DEFAULT_TIME) autoit.send(member.last_name.upper()) autoit.send('{TAB}') autoit.send(member.first_name.upper()) autoit.send('{TAB}') time.sleep(DEFAULT_TIME) autoit.send(member.birthdate.strftime(DATE_FORMAT)) autoit.send("{TAB}") time.sleep(1.0) if hex(autoit.pixel_get_color(2877, 223)) == '0xf4b04f': if member.first_name.find('KID') != -1: print('duplicated detected for KID') autoit.mouse_click("left", 2872, 292) time.sleep(3.0) y = 438 while hex(autoit.pixel_get_color(2902, y)) != '0xe66252': y += 1 autoit.mouse_click('left', 2902, y) time.sleep(2.0) autoit.mouse_click("left", 3101, 326) time.sleep(2.0) else: write_duplicate(member.first_name, member.last_name, member.birthdate) print('duplicate detected in household member %s' % str(member)) return False autoit.mouse_click("left", 2567, 312) autoit.send('{TAB}') if member.gender == "female": autoit.send('{DOWN}') elif member.gender == "male": autoit.send('{DOWN}{DOWN}') else: autoit.send('{DOWN}{DOWN}{DOWN}{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') autoit.send('{TAB}') autoit.send('{DOWN}') time.sleep(DEFAULT_TIME) if relationship == 'spouse': autoit.send('{DOWN}') elif relationship == 'child': autoit.send('{DOWN}{DOWN}') else: for i in range(9): autoit.send('{DOWN}') time.sleep(DEFAULT_TIME) autoit.send('{ENTER}') if relationship == 'child': autoit.mouse_click("left", 2450, 350) time.sleep(DEFAULT_TIME) autoit.mouse_click("left", 2669, 423) time.sleep(DEFAULT_TIME) click_point_from_city_member(member.city) time.sleep(DEFAULT_TIME) if member.birthdate.year >= 2002: autoit.mouse_click("left", 3231, 754) else: autoit.mouse_click("left", 2449, 720) time.sleep(DEFAULT_TIME) autoit.mouse_click("left", 3231, 867) time.sleep(1.0) return True
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))
import autoit size = autoit.win_get_client_size("Program Manager") print(size) color = autoit.pixel_get_color(0, 0) print(color)