Пример #1
0
class GuiWang():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()

    def task_start(self):
        print("任务开始")
        self.common.get_focus()
        for j in range(3):
            self.mouse.click_element(675, 366, 1, True)
            time.sleep(2.5)
        self.keyboard.press_shortcut_key('alt', '5')
        time.sleep(10)
        # 领取任务
        while True:
            print("领取任务")
            self.mouse.click_element(392, 350)
            time.sleep(1)
            self.screen.cut_screen()
            result = self.screen.get_locations_picture(
                "D:\\dh2\\game\\guiwang\\0.png", 0.9)
            if result is not 0:
                self.mouse.click_element(225, 383)
                time.sleep(0.5)
                self.mouse.click_element(180, 353)
                time.sleep(0.5)
                self.mouse.click_element(180, 353)
                result_king = self.is_ghostKing()
                if result_king is True:
                    self.mouse.click_element(392, 350)
                    time.sleep(1)
                    self.screen.cut_screen()
                    result = self.screen.get_locations_picture(
                        "D:\\dh2\\game\\guiwang\\0.png", 0.9)
                    if result is not 0:
                        self.mouse.click_element(268, 330)
                        time.sleep(1)
                        self.mouse.click_element(268, 330)
                else:
                    break
        # 返回长安 开始寻路
        print("返回长安")
        while True:
            self.mouse.click_element(392, 350)
            time.sleep(1)
            self.screen.cut_screen()
            result = self.screen.get_locations_picture(
                "D:\\dh2\\game\\guiwang\\0.png", 0.75)
            if result is not 0:
                self.mouse.click_element(268, 365)
                time.sleep(2)
                self.mouse.click_element(29, 255)
                break

        self.common.capation_eat_xiang()
        # 找到NPC,开始战斗
        print("找NPC")
        time.sleep(10)
        self.screen.find_ele_picture('game\\guiwang\\1', 'mouse', 210, 340)
        for index in range(5):
            time.sleep(2)
            self.keyboard.press_shortcut_key('alt', '8')
            self.common.change_teamer()
            self.mouse.click_element(412, 429)
        time.sleep(10)
        self.screen.find_ele_picture('game\\guiwang\\2_', 'mouse', 172, 340)
        time.sleep(1)
        self.screen.cut_screen()
        time.sleep(1)
        ress = self.screen.get_locations_picture(
            "D:\\dh2\\game\\guiwang\\2_.png", 0.7)
        self.mouse.click_element(ress[0]['result'][0], ress[0]['result'][1])
        time.sleep(1)
        self.mouse.click_element(784, 539)
        time.sleep(1)
        print("回家 判断")
        self.return_home()
        time.sleep(1)
        Screen().cut_screen()
        box_result = Screen().get_location_picture(
            'D:\\dh2\\game\\xiaogui\\3.png', 0.8)
        if box_result is not 0:
            Mouse().click_element(327, 535)

    def is_ghostKing(self):
        self.screen.cut_screen_by_PIL(20, 265, 50, 300,
                                      "D:\\dh2\\system\\1.PNG")
        result = self.screen.find_color_ele(10, 10, 8, 8, 255, 255, 0, 0, 0, 0,
                                            True)
        if result is not None:
            return True
        else:
            return False

    def return_home(self):
        time.sleep(1)
        self.screen.cut_screen()
        result = self.screen.get_locations_picture(
            "D:\\dh2\\game\\guiwang\\3.png", 0.7)
        print(result)
        if len(result) is not 0:
            self.mouse.click_element(757, 455, 1, True)
            time.sleep(1.5)
            self.mouse.click_element(757, 455, 1, True)
            self.mouse.click_element(569, 450)
            self.mouse.click_element(178, 347)
Пример #2
0
class DaYanTa():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()

    def make_sure(self):
        self.common.get_focus()
        for i in range(3):
            self.mouse.click_element(311, 490)
            self.common.change_teamer()
        self.common.get_focus()

    def make_sure_wuyi(self):
        for i in range(3):
            self.mouse.click_element(183, 347)
            self.common.change_teamer()
        self.common.get_focus()

    def game_over(self):
        endtime = time.time() + int(300)
        while time.time() < endtime:
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            result_ = self.screen.get_location_picture(
                "D:\\dh2\\game\\system\\zidong.png", num=0.8)
            if result_ is 0:
                return True
        return False

    def operate(self):
        result_ = self.screen.find_ele_picture_time('game\\system\\zidong')
        if result_ is True:
            for i in range(3):
                self.keyboard.press_shortcut_key('alt', '8')
                if i is not 2:
                    self.common.change_teamer()
        self.common.get_focus()

    def start_task(self):
        self.common.get_focus()
        self.keyboard.press_shortcut_key('alt', '1')
        self.mouse.click_element(202, 254)
        time.sleep(10)
        # 寻找NPC 185,380
        self.screen.find_ele_picture('yitiao\\dayanta\\begin')
        self.mouse.click_element(177, 349, times=0.5)
        time.sleep(2)
        self.make_sure()
        time.sleep(5)
        # 第一个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\1', 'mouse', 180, 361)
        self.mouse.click_element(91, 240, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\1_2', 'mouse', 169, 339)
        self.operate()
        self.game_over()
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\1_3', 'mouse', 175, 344)
        time.sleep(3)
        # 第二个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\2', 'mouse', 180, 361)
        time.sleep(1)
        pyautogui.click()
        self.mouse.click_element(78, 240, times=0.5)
        time.sleep(60)
        res = self.screen.get_locations_picture(
            "D:\\dh2\\yitiao\\dayanta\\2_1.png", 0.7)
        self.mouse.click_element(res[0]['result'][0], res[0]['result'][1])
        time.sleep(1)
        self.mouse.click_element(91, 241, times=0.5)
        time.sleep(1)
        self.mouse.click_element(173, 327, times=0.5)
        self.operate()
        self.game_over()
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\2_2', 'mouse', 183, 325)
        time.sleep(3)
        # 第三个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\3', 'mouse', 180, 413)
        self.mouse.click_element(91, 240, times=0.5)
        self.operate()
        self.game_over()
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\3_1', 'mouse', 175, 344)
        time.sleep(3)
        # 第四个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\4', 'mouse', 180, 361)
        time.sleep(1)
        pyautogui.click()
        while True:
            time.sleep(4)
            self.mouse.click_element(41, 240, times=0.5)
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            location = self.screen.get_locations_picture(
                "D:\\dh2\\yitiao\\dayanta\\4_1.png", 0.9)
            if len(location) is not 0:
                self.mouse.click_element(178, 365, times=0.5)
                break
        self.make_sure()
        self.operate()
        self.game_over()
        while True:
            time.sleep(4)
            self.mouse.click_element(33, 255, times=0.5)
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            location = self.screen.get_locations_picture(
                "D:\\dh2\\yitiao\\dayanta\\4_2.png", 0.7)
            if len(location) is not 0:
                self.mouse.click_element(183, 343, times=0.5)
                break
        time.sleep(3)
        # 第五个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\5', 'mouse', 180, 344)
        time.sleep(1)
        pyautogui.click()
        while True:
            time.sleep(4)
            self.mouse.click_element(150, 240, times=0.5)
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            location = self.screen.get_locations_picture(
                "D:\\dh2\\yitiao\\dayanta\\5_1.png", 0.7)
            if len(location) is not 0:
                self.mouse.click_element(178, 365, times=0.5)
                break
        self.make_sure()
        self.operate()
        self.game_over()
        while True:
            time.sleep(4)
            self.mouse.click_element(33, 255, times=0.5)
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            location = self.screen.get_locations_picture(
                "D:\\dh2\\yitiao\\dayanta\\5_2.png", 0.7)
            if len(location) is not 0:
                self.mouse.click_element(190, 365, times=0.5)
                break
        time.sleep(3)
        # 第六个
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\6', 'mouse', 180, 381)
        time.sleep(1)
        pyautogui.click()
        self.mouse.click_element(41, 240, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\6_1', 'mouse', 182, 353)
        self.make_sure()
        self.operate()
        self.game_over()
        self.mouse.click_element(30, 257, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\6_2', 'mouse', 175, 344)
        time.sleep(3)
        # 第七个
        self.mouse.click_element(156, 240, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\7', 'mouse', 180, 345)
        time.sleep(1)
        self.mouse.click_element(54, 240, times=0.5)
        time.sleep(1)
        self.mouse.click_element(461, 292, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\7_1', 'mouse', 182, 329)
        self.operate()
        self.game_over()
        self.mouse.click_element(85, 243, times=0.5)
        self.screen.find_ele_picture('yitiao\\dayanta\\7_2', 'mouse', 192, 330)
        self.keyboard.press_shortcut_key('alt', 'q')
        time.sleep(3)