def click_task(x): """ 领取任务 :param x: 领取第几个任务 :return: """ MouseUtil().left_click(165, 244 + (x * 19))
def click_tool_bar(x): """ 打开物品栏 :param x: 点第几个栏 :return: """ MouseUtil().left_click(493 + (x * 30), 615)
def select_inventory(x): """ 选择背包 :param x: 第几个背包 :return: """ MouseUtil().left_click(762, 314 + (x * 51))
def replenish_piece(task_flag, spare_flag, buy_flag): """ :param task_flag: :param spare_flag: :param buy_flag: :return: """ task_flag.times_left = task_flag.times_left - 1 if task_flag.times_left == 0: move_goods_two(spare_flag.goods_position_y, spare_flag.goods_position_x, task_flag.goods_position_y, task_flag.goods_position_x) MouseUtil().click_right() task_flag.times_left = 30 fly_destination(buy_flag.goods_position_y, buy_flag.goods_position_x) buy_flag.times_left = buy_flag.times_left - 1 # 关闭物品栏 click_tool_bar(1) # 购买第一个物品 if buy_flag.times_left == 0: buy_grocery(1, 1, 2) else: buy_grocery(1, 1, 1) # 打开物品栏 click_tool_bar(1) if buy_flag.times_left == 0: right_goods(buy_flag.goods_position_y, buy_flag.goods_position_x) buy_flag.times_left = 30
def buy_grocery(y, x, num): """ 杂货店购买物品 :param y: 第几行 :param x: 第几个 :return: """ # 点击npc MouseUtil().left_click(585, 400) # 点击第一个购买物品 click_task(1) # 鼠标移动到对应的飞行棋上面 MouseUtil().left_click(229 + (51 * x), 131 + (51 * y)) # 购买 for i in range(num): MouseUtil().left_click(405, 507) # 关闭 MouseUtil().left_click(568, 120)
def left_goods(y, x): """ 左键选择指定位置的物品 :param y: 水平位置(取值范围1-6) :param x: 垂直位置(取值范围1-4) :return: """ horizontal_one = 471 vertical_one = 366 distance = 51 horizontal_one = horizontal_one + ((x - 1) * distance) vertical_one = vertical_one + ((y - 1) * distance) MouseUtil().left_click(horizontal_one, vertical_one)
def right_goods(y, x): """ 右键使用指定位置的物品,比如飞行棋 :param y: 水平位置(取值范围1-6) :param x: 垂直位置(取值范围1-4) :return: """ horizontal_one = 471 vertical_one = 366 distance = 51 horizontal_one = horizontal_one + ((x - 1) * distance) vertical_one = vertical_one + ((y - 1) * distance) MouseUtil().right_click(horizontal_one, vertical_one)
def ling_sha_santou(m_list, monit, dijici): for i in m_list: # 打开客户端 MouseUtil().left_click((m_list.index(i) + 2) * 160 - 29, monit[-1] - 20) lis = get_flight_flag_info('./' + i + '.txt') spare_flag = get_flag_name(lis, '备用棋') buy_flag = get_flag_name(lis, '长安杂货店(12,11)') # 领取做天任务 task_flag = get_flag_name(lis, '天宫(37,33)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) time.sleep(3) # 左键点击npc,领取任务 MouseUtil().left_click(310, 200) click_task(1) if dijici == 0: time.sleep(6) click_tool_bar(1) click_tool_bar(1) else: time.sleep(3) MouseUtil().click_left() replenish_piece(task_flag, spare_flag, buy_flag) # 杀三头魔王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(10,35)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(3) MouseUtil().left_click(190, 300) if task_flag.times_left == 1: time.sleep(26) replenish_piece(task_flag, spare_flag, buy_flag) else: task_flag.times_left = task_flag.times_left - 1 save_flight_flag(lis, './' + i + '.txt') MouseUtil().left_click((m_list.index(i) + 2) * 160 - 29, monit[-1] - 20)
def sha_lanse(m_list, monit): for i in m_list: # 打开客户端 MouseUtil().left_click((m_list.index(i) + 2) * 160 - 29, monit[-1] - 20) lis = get_flight_flag_info('./' + i + '.txt') spare_flag = get_flag_name(lis, '备用棋') buy_flag = get_flag_name(lis, '长安杂货店(12,11)') # 杀蓝色妖王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(105,45)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(3) MouseUtil().left_click(280, 240) if task_flag.times_left == 1: time.sleep(26) replenish_piece(task_flag, spare_flag, buy_flag) else: time.sleep(6) task_flag.times_left = task_flag.times_left - 1 save_flight_flag(lis, './' + i + '.txt') MouseUtil().left_click((m_list.index(i) + 2) * 160 - 29, monit[-1] - 20)
def zuo_tian(path, four, nineteen, dijici): lis = get_flight_flag_info(path) spare_flag = get_flag_name(lis, '备用棋') buy_flag = get_flag_name(lis, '长安杂货店(12,11)') # 领取做天任务 task_flag = get_flag_name(lis, '天宫(37,33)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) time.sleep(four) # 左键点击npc,领取任务 MouseUtil().left_click(310, 200) click_task(1) if dijici == 100: time.sleep(6) click_tool_bar(1) click_tool_bar(1) else: time.sleep(four) MouseUtil().click_left() replenish_piece(task_flag, spare_flag, buy_flag) # 杀三头魔王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(10,35)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(four) MouseUtil().left_click(190, 300) time.sleep(nineteen) replenish_piece(task_flag, spare_flag, buy_flag) # 杀黑山妖王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(100,10)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(four) MouseUtil().left_click(230, 300) time.sleep(nineteen) replenish_piece(task_flag, spare_flag, buy_flag) # 杀蓝色妖王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(105,45)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(four) MouseUtil().left_click(280, 240) time.sleep(nineteen) replenish_piece(task_flag, spare_flag, buy_flag) # 杀万年熊王 # 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(110,100)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(four) MouseUtil().left_click(480, 580) time.sleep(nineteen) replenish_piece(task_flag, spare_flag, buy_flag) save_flight_flag(lis, path)
# 使用指定位置的飞行棋飞到指定位置 task_flag = get_flag_name(lis, '御马监(110,100)') fly_destination(task_flag.goods_position_y, task_flag.goods_position_x) # 左键点击npc,领取任务 time.sleep(3) MouseUtil().left_click(480, 580) if task_flag.times_left == 1: time.sleep(26) replenish_piece(task_flag, spare_flag, buy_flag) else: time.sleep(6) task_flag.times_left = task_flag.times_left - 1 save_flight_flag(lis, './' + i + '.txt') MouseUtil().left_click((m_list.index(i) + 2) * 160 - 29, monit[-1] - 20) if __name__ == '__main__': t = time.time() for i in range(50): ling_sha_santou(lis, monitor, i) sha_heishan(lis, monitor) sha_lanse(lis, monitor) sha_wannian(lis, monitor) for i in lis: MouseUtil().left_click(2 * 160 - 29, monitor[-1] - 20) fly_destination(4, 1) MouseUtil().left_click(790, 15) a = time.time() print(int(a) - int(t))
import time from pynput.keyboard import Controller, Key from pynput.keyboard import Controller from util.MouseUtil import MouseUtil from util.ZuoTianUtil import click_tool_bar, right_goods screen = [1920, 1080] # MouseUtil().right_click(screen[0] - 100, screen[-1]) # MouseUtil().left_click(315, 50) MouseUtil().move_to(790, 15)
import time from pynput.keyboard import Controller from pynput.keyboard import Key from util.MouseUtil import MouseUtil from util.ZuoTianUtil import click_tool_bar, right_goods keyboard = Controller() list1 = ['a979899', 'b979899', 'c979899'] screen = [1920, 1080] # 显示桌面 MouseUtil().right_click(screen[0], screen[-1]) keyboard.press('s') keyboard.release('s') for user in list1: print(list1.index(user)) # 打开大话西游 MouseUtil().move_to(36, 44) MouseUtil().click_left_two() time.sleep(6) # 堆叠窗口 MouseUtil().right_click(screen[0] - 100, screen[-1]) keyboard.press('e') keyboard.release('e') MouseUtil().left_click(680, 170) MouseUtil().left_click(260, 155) MouseUtil().left_click(600, 270) time.sleep(1) for i in range(10): keyboard.press(Key.backspace)