Beispiel #1
0
    def dou_ji(self, y1, y2, y3, y4, inum, imax_times):
        windowslist = [y1, y2, y3, y4]
        #只有一个结界类实例,不同的只是窗口句柄和窗口坐标
        game = Dou_ji()
        yys1 = Handle()
        yys2 = Handle()
        yys3 = Handle()
        yys4 = Handle()
        yyslist = [yys1, yys2, yys3, yys4]

        i = 0
        while i < inum:
            if self.set_yys(windowslist[i], game, yyslist[i]) != 0:
                self.add_log("沙盒窗口不完全存在,进程结束。\r\n")
                return codedef.NORMAL_END
            i = i + 1

        finishlist = [False, False, False, False]
        waitlist = [0, 0, 0, 0]
        ji_shulist = [0, 0, 0, 0]
        ju_flag = [False, False, False, False]

        while 1:
            i = 0
            while i < inum:
                if finishlist[i] is False:
                    scene = game.get_scene(yyslist[i])
                    self.add_log(scene.__str__() + "\r\n")
                    re = game.do_work(scene, yyslist[i])
                    if re == codedef.SCENCE_REPEAT_END:
                        finishlist[i] = True
                        self.add_log("yys" + windowslist[i] + "场景重复超限\r\n")
                        self.send_qq_jie_tu(yyslist[i])
                    elif re == codedef.FIGHT_BEGIN:
                        ju_flag[i] = True
                    elif re == codedef.FIGHT_END and ju_flag[i] is True:
                        ju_flag[i] = False
                        ji_shulist[i] += 1
                        self.add_log(ji_shulist[i].__str__() + "\r\n")
                        if ji_shulist[i] > imax_times:
                            finishlist[i] = True
                    self.time_sleep(inum)
                i = i + 1
            i = 0
            while i < inum:
                if finishlist[i] is False:
                    break
                i = i + 1
            if i == inum:
                break
        self.send_qq(r'斗技 打完,进程结束')
        return codedef.NORMAL_END
Beispiel #2
0
    def team_kun_25_one(self, captain, UP, BOSS, QingMax, Beater, BeatMax,
                        imax_times, Chapter):
        game = Team_kun_25_captain(UP=UP,
                                   BOSS=BOSS,
                                   QingMax=QingMax,
                                   Beater=Beater,
                                   BeatMax=BeatMax,
                                   Chapter=Chapter,
                                   IsOne=True)
        yys1 = Handle()
        self.set_yys(captain, game, yys1)
        times = 0
        ju_flag = False

        oldc_c = ''

        while 1:
            # 队长
            scene = game.get_scene(yys1)
            if oldc_c != str(scene):
                oldc_c = str(scene)
                self.add_log(str(scene) + "\r\n")
            re = game.do_work(scene, yys1)
            if re > 0:
                self.add_log('队长满级数量' + str(re) + "\r\n")
            if re == codedef.BEGIN_DA_GUAI or re == codedef.BEGIN_DA_BOSS:
                ju_flag = True
            elif re == codedef.FIGHT_END and ju_flag is True:
                game.set_da_guai(True)
                ju_flag = False
                times = times + 1
                self.add_log(times.__str__() + "\r\n")
                if times > imax_times:
                    self.add_log("达到最大次数,进程结束\r\n")
                    self.send_qq(r'困25 达到最大次数,进程结束')
                    return codedef.NORMAL_END
            elif re == codedef.SCENCE_REPEAT_END:
                self.add_log("场景重复超限\r\n")
                self.send_qq_jie_tu(yys1)
                return codedef.NORMAL_END
            elif re == codedef.TANG_GO_RIGHT:
                yys1.iold_scene = 0
            elif re == codedef.EXIT_TANG_SUO:
                game.set_yao_qing(True)  # 队长可邀请
            elif re == codedef.YAO_QING_ZHONG:
                yys1.iold_scene = 0
        pass
Beispiel #3
0
 def set_windows(self, yys):
     if yys == "" or yys == " ":
         self.add_log("阴阳师 参数不对\r\n")
         return codedef.ERROR_END
     game = Game()
     yys1 = Handle()
     self.set_yys(yys, game, yys1)
     return codedef.NORMAL_END
Beispiel #4
0
 def dian_guai_11(self):
     yys1 = self.comboBox_1.currentText()
     yys_handle = Handle()
     self.add_in_text_browser("点主怪\r\n")
     if Window.get_window(yys_handle, None, "[#] [yys" + yys1 + "] 阴阳师-网易游戏 [#]") == codedef.NORMAL_END:
         x = int((yys_handle.right + yys_handle.left) / 2)
         xishu = 0.2
         y = int((yys_handle.top + (yys_handle.bottom - yys_handle.top) * xishu))
         m = Mouse()
         m.click(x, y)
Beispiel #5
0
    def test_main(self):
        # 测试函数:截取游戏窗口temp.bmp
        # 再截出N卡的小块,确定准确后的百分比
        handle = Handle()
        game = Game()

        arr12 = [[2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6],
                 [2, 7], [0, 1], [0, 4], [0, 7], [1, 1], [1, 4], [1, 7]]

        if self.set_yys("1", game, handle) == 0:
            # while 1:
            game.get_scene(handle)  # 产生temp.bmp
            # metrics_x = GetSystemMetrics(0)  # 获取分辨率
            # metrics_y = GetSystemMetrics(1)  # 获取分辨率
            # gou = Gouliang(metrics_x, metrics_y, handle)
            # gou.find_and_huang(False, False)
            # n 卡分块
            print("kais")
            top = 0.25
            left = 0.15
            bottom = codedef.n_bottom
            right = codedef.n_right
            kuang = int(0.1 * (handle.right - handle.left))

            img = Img()
            name = 0
            j = 0
            while j < 4:
                i = 0
                while i < 8:
                    # p = arr12[name]
                    # i = p[1]
                    # j = p[0]
                    point = [
                        int(left *
                            (handle.right - handle.left)) + kuang * (i + 0),
                        int(top * (handle.bottom - handle.top)) + kuang *
                        (j + 0)
                    ]
                    point2 = [
                        int(left *
                            (handle.right - handle.left)) + kuang * (i + 1),
                        int(top * (handle.bottom - handle.top)) + kuang *
                        (j + 1)
                    ]

                    tag_img = img.cut_img_path('temp/temp.bmp', point, point2)

                    img.save("temp/t" + str(name) + ".bmp", tag_img)

                    i += 1
                    name += 1
                    time.sleep(0.2)
                j += 1
Beispiel #6
0
def testtt():
    h = Window.check_window("[#] [yys1] 阴阳师-网易游戏 [#]")
    print(h)
    sleep_time = 1
    if h != 0:
        game = Team_kun_25_captain(codedef.UP_C_COIN, False)
        yys1 = Handle()
        win32gui.ShowWindow(yys1.hwnd, 1)
        re = game.set_window(yys1, "[#] [yys1] 阴阳师-网易游戏 [#]", 1, True)
        if re != 0:
            return re
        while 1:
            scene = game.get_scene(yys1)
            captain_wait = game.do_work(scene, yys1)
            time.sleep(2)
Beispiel #7
0
    def jie_jie(self, y1, y2, y3, y4, inum, maxt=False):
        windowslist = [y1, y2, y3, y4]
        #只有一个结界类实例,不同的只是窗口句柄和窗口坐标
        game = Personal_jiejie()
        yys1 = Handle()
        yys2 = Handle()
        yys3 = Handle()
        yys4 = Handle()
        yyslist = [yys1, yys2, yys3, yys4]

        i = 0
        while i < inum:
            if self.set_yys(windowslist[i], game, yyslist[i]) != 0:
                self.add_log("沙盒窗口不完全存在,进程结束。\r\n")
                return codedef.NORMAL_END
            i = i + 1

        finishlist = [0, 0, 0, 0]
        waitlist = [0, 0, 0, 0]

        while 1:
            i = 0
            while i < inum:
                if finishlist[i] != 2:
                    if waitlist[i] == 0:
                        scene = game.get_scene(yyslist[i])
                        if scene == SceneKey.TANG_SUO and finishlist[i] == 1:
                            finishlist[i] = 2
                            continue
                        self.add_log(scene.__str__() + "\r\n")
                        if finishlist[i] == 0:
                            print("do_work" + str(i))
                            re = game.do_work(scene, yyslist[i])
                        elif finishlist[i] == 1:
                            print("exit" + str(i))
                            re = game.exit(scene, yyslist[i])
                        else:
                            print("NORMAL_END" + str(i))
                            re = codedef.NORMAL_END

                        if re == codedef.SCENCE_REPEAT_END:
                            finishlist[i] = 1
                            self.add_log("yys" + windowslist[i] + "场景重复超限\r\n")
                            self.send_qq_jie_tu(yyslist[i])
                        elif re > codedef.NORMAL_END:
                            yyslist[i].iold_scene = 0
                            waitlist[i] = re
                            self.add_log("yys" + windowslist[i] +
                                         "冷却中,场景重复次数重置\r\n")
                            # if maxt:
                            #     finishlist[i] = 1

                    else:
                        waitlist[i] = waitlist[i] - 1
                    if waitlist[i] < 0:
                        waitlist[i] = 0
                    self.time_sleep(inum)
                i = i + 1
            i = 0
            while i < inum:
                if finishlist[i] != 2:
                    break
                i = i + 1
            if i == inum:
                break
        self.send_qq(r'结界全部 打完,进程结束')
        return codedef.NORMAL_END
Beispiel #8
0
    def team_kun_25(self, captain, teammate, UP, BOSS, QingMax, Beater,
                    BeatMax, imax_times, Chapter):
        if Window.check_window("[#] [yys" + captain + "] 阴阳师-网易游戏 [#]") == 0 \
                or Window.check_window("[#] [yys" + teammate + "] 阴阳师-网易游戏 [#]") == 0:
            self.add_log("沙盒窗口不完全存在,进程结束。\r\n")
            return codedef.NORMAL_END

        if captain == teammate:
            self.add_log("单人探索\r\n")
            self.team_kun_25_one(captain, UP, BOSS, QingMax, Beater, BeatMax,
                                 imax_times, Chapter)
            return codedef.NORMAL_END

        game = Team_kun_25_captain(UP=UP,
                                   BOSS=BOSS,
                                   QingMax=QingMax,
                                   Beater=Beater,
                                   BeatMax=BeatMax,
                                   Chapter=Chapter)
        yys1 = Handle()
        self.set_yys(captain, game, yys1)
        game2 = Team_kun_25_teammate(Beater=Beater, BeatMax=BeatMax)
        yys2 = Handle()
        self.set_yys(teammate, game2, yys2)
        times = 0
        ju_flag = False

        oldc_c = ''

        while 1:
            # 队长
            scene = game.get_scene(yys1)
            if oldc_c != str(scene):
                oldc_c = str(scene)
                self.add_log(str(scene) + "\r\n")
            re = game.do_work(scene, yys1)
            if re > 0:
                self.add_log('队长满级数量' + str(re) + "\r\n")
            if re == codedef.BEGIN_DA_GUAI or re == codedef.BEGIN_DA_BOSS:
                ju_flag = True
            elif re == codedef.FIGHT_END and ju_flag is True:
                ju_flag = False
                times = times + 1
                self.add_log(times.__str__() + "\r\n")
                if times > imax_times:
                    self.add_log("达到最大次数,进程结束\r\n")
                    self.send_qq(r'困25 达到最大次数,进程结束')
                    return codedef.NORMAL_END
            elif re == codedef.SCENCE_REPEAT_END:
                self.add_log("场景重复超限\r\n")
                self.send_qq_jie_tu(yys1)
                return codedef.NORMAL_END
            elif re == codedef.TANG_GO_RIGHT:
                yys1.iold_scene = 0
                yys2.iold_scene = 0
            elif re == codedef.EXIT_TANG_SUO:
                game2.set_exit(True)
            elif re == codedef.YAO_QING_ZHONG:
                yys1.iold_scene = 0
                yys2.iold_scene = 0

            # 队员
            scene = game2.get_scene(yys2)

            if oldc_c != str(scene):
                oldc_c = str(scene)
                self.add_log(str(scene) + "\r\n")

            if scene == SceneKey.TANG_SUO or scene == SceneKey.TANG_SUO_ZHANG_JIE:
                game.set_yao_qing(True)  # 队长可邀请

            re = game2.do_work(scene, yys2)
            if re > 0:
                self.add_log('队友满级数量' + str(re) + "\r\n")
            if re == codedef.ZAI_TANG_SUO:
                game.set_da_guai(True)
Beispiel #9
0
    def xue_yue(self,
                y1,
                y2,
                y3,
                y4,
                inum,
                imax_times,
                mod,
                fengmod=None,
                buyyan=0,
                buyyu=0):
        windowslist = [y1, y2, y3, y4]

        if mod == codedef.CHOU_N_KA:
            game = Nka()
        elif mod == codedef.ZA_BAI_GUI:
            game = Zabaigui()
        elif mod == codedef.XUE_YUE:
            game = dashitou()
        elif mod == codedef.FENG_MO:
            game = fengmo(fengmod)
        elif mod == codedef.SHENG_XING:
            game = shengxing()
        elif mod == codedef.RI_LUN_YU:
            game = rilunzhicheng(buyyan=buyyan, buyyu=buyyu, mod=0)
        elif mod == codedef.RI_LUN_CENG:
            game = rilunzhicheng(buyyan=buyyan, buyyu=buyyu, mod=1)
        else:
            game = dashitou()

        yys1 = Handle()
        yys2 = Handle()
        yys3 = Handle()
        yys4 = Handle()
        yyslist = [yys1, yys2, yys3, yys4]

        i = 0
        while i < inum:
            if self.set_yys(windowslist[i], game, yyslist[i]) != 0:
                self.add_log("沙盒窗口不完全存在,进程结束。\r\n")
                return codedef.NORMAL_END
            i = i + 1

        finishlist = [False, False, False, False]
        waitlist = [0, 0, 0, 0]
        ji_shulist = [0, 0, 0, 0]
        ju_flag = [False, False, False, False]

        while 1:
            i = 0
            while i < inum:
                if finishlist[i] is False:
                    re = codedef.NORMAL_END
                    if waitlist[i] == 0:
                        scene = game.get_scene(yyslist[i])
                        self.add_log(scene.__str__() + "\r\n")
                        re = game.do_work(scene, yyslist[i])
                        # self.add_log(str(re) + "\r\n")
                        if re > codedef.NORMAL_END:
                            waitlist[i] = re
                        elif re == codedef.FIGHT_BEGIN:
                            ju_flag[i] = True
                        elif re == codedef.FIGHT_END and ju_flag[i] is True:
                            ju_flag[i] = False
                            ji_shulist[i] = ji_shulist[i] + 1
                            self.add_log("第" + ji_shulist[i].__str__() + "次" +
                                         "\r\n")
                            if ji_shulist[i] >= imax_times:
                                finishlist[i] = True
                        elif re == codedef.SCENCE_REPEAT_END:
                            finishlist[i] = True
                            self.add_log("yys" + windowslist[i] + "场景重复超限\r\n")
                            self.send_qq_jie_tu(yyslist[i])

                    else:
                        waitlist[i] = waitlist[i] - 1
                    if int(waitlist[i]) < 0:
                        waitlist[i] = 0
                    if re != codedef.ERROR_END:
                        self.time_sleep(inum)
                i = i + 1
            i = 0
            while i < inum:
                if finishlist[i] is False:
                    break
                i = i + 1
            if i == inum:
                break
        self.send_qq(r'进程结束')
        return codedef.NORMAL_END
Beispiel #10
0
    def hun_shi(self, y1, y2, y3, imax_times):
        if Window.check_window("[#] [yys" + y1 + "] 阴阳师-网易游戏 [#]") == 0 \
                or Window.check_window("[#] [yys" + y2 + "] 阴阳师-网易游戏 [#]") == 0 \
                or Window.check_window("[#] [yys" + y3 + "] 阴阳师-网易游戏 [#]") == 0:
            self.add_log("沙盒窗口不完全存在,进程结束。\r\n")
            return codedef.NORMAL_END

        game = Team_hun_10()
        yys1 = Handle()
        yys2 = Handle()
        yys3 = Handle()
        self.set_yys(y1, game, yys1)
        self.set_yys(y2, game, yys2)
        self.set_yys(y3, game, yys3)
        ju_flag = False
        # dian_guai_flag = 0
        # dian_guai_time = 0
        times = 0
        # t = time.time()

        # print(t)  # 原始时间数据
        # print(int(t))
        re1 = codedef.NORMAL_END
        re2 = codedef.NORMAL_END
        re3 = codedef.NORMAL_END
        while 1:
            scene = game.get_scene(yys1)

            # 手动阵容需点怪
            # if scene == SceneKey.ZHANG_DOU_ZHONG or scene == SceneKey.NUKOWN:
            #     if dian_guai_flag == 1:
            #         dian_guai_flag = 2
            #         dian_guai_time = int(time.time())
            #     elif dian_guai_flag == 2 and int(time.time()) - dian_guai_time >= 11:
            #         dian_guai_flag = 3
            #         game.dian_guai_11(yys1)
            #         self.add_log("yys" + y1 + "点主怪\r\n")
            #         time.sleep(1)
            #         game.dian_guai_11(yys1)
            #
            #     elif dian_guai_flag == 3 and int(time.time()) - dian_guai_time >= 27:
            #         dian_guai_flag = 4
            #         game.dian_guai_11(yys1)
            #         self.add_log("yys" + y1 + "点主怪\r\n")
            #         time.sleep(1)
            #         game.dian_guai_11(yys1)
            #
            #     elif dian_guai_flag == 4 and int(time.time()) - dian_guai_time >= 27:   # 34
            #         dian_guai_flag = 5
            #         game.dian_guai_11(yys1)
            #         self.add_log("yys" + y1 + "点主怪\r\n")
            #         time.sleep(1)
            #         game.dian_guai_11(yys1)
            # 手动阵容需点怪

            re1 = game.do_work(scene, yys1)
            self.add_log(scene.__str__() + str(re1) + "\r\n")
            if re1 == codedef.SCENCE_REPEAT_END:
                self.add_log("yys" + y1 + "场景重复超限\r\n")
                self.send_qq_jie_tu(yys1)
            elif re1 == codedef.FIGHT_BEGIN and ju_flag is False:
                ju_flag = True
                # dian_guai_flag = 1
            elif re1 == codedef.FIGHT_END and ju_flag is True:
                # dian_guai_time = 0
                # dian_guai_flag = 0
                ju_flag = False
                times += 1
                self.add_log(times.__str__() + "\r\n")
                if times > imax_times:
                    self.add_log("达到最大次数,进程结束\r\n")
                    self.send_qq(r'御魂觉醒 达到最大次数,进程结束')
                    return codedef.NORMAL_END
            elif re1 == codedef.HUN_SHI_TEAMING and re2 == codedef.HUN_SHI_TEAMING and re3 == codedef.HUN_SHI_TEAMING:
                self.add_log("teaming\r\n")
                game.teaming(scene, yys1)

            if scene == SceneKey.GOU_MAI_TI_LI:
                break

            time.sleep(0.6)
            scene = game.get_scene(yys2)
            re2 = game.do_work(scene, yys2)
            if re2 == codedef.SCENCE_REPEAT_END:
                self.add_log("yys" + y2 + "场景重复超限\r\n")
                self.send_qq_jie_tu(yys2)
            self.add_log(scene.__str__() + "\r\n")
            if scene == SceneKey.GOU_MAI_TI_LI:
                break
            time.sleep(0.6)
            scene = game.get_scene(yys3)
            re3 = game.do_work(scene, yys3)
            if re3 == codedef.SCENCE_REPEAT_END:
                self.add_log("yys" + y3 + "场景重复超限\r\n")
                self.send_qq_jie_tu(yys3)
            self.add_log(scene.__str__() + "\r\n")
            if scene == SceneKey.GOU_MAI_TI_LI:
                break
            time.sleep(0.6)

        self.send_qq(r'魂十 打完,进程结束')
        return codedef.NORMAL_END
Beispiel #11
0
class SendQQ:
    m_handle = Handle()

    def __init__(self, name):
        class_name = None
        re = Window.get_window(self.m_handle, class_name, name)
        if re != 0:
            print("找不到窗口:" + name)
            #self.add_log("找不到窗口:" + name + str(handle.hwnd) + "\r\n")
        else:
            print("窗口:" + name)
            #self.add_log("窗口:" + name + str(handle.hwnd) + "\r\n")

    @staticmethod
    def get_clipboard_text():
        """获取剪贴板文本"""
        w.OpenClipboard()
        d = w.GetClipboardData(win32con.CF_UNICODETEXT)
        w.CloseClipboard()
        return d

    @staticmethod
    def set_image(data):
        w.OpenClipboard()  # 打开剪贴板
        w.EmptyClipboard()  # 先清空剪贴板
        w.SetClipboardData(win32con.CF_BITMAP, data)  # 将图片放入剪贴板
        w.CloseClipboard()
        return 0

    @staticmethod
    def set_text(aString):
        """设置剪贴板文本"""
        w.OpenClipboard()
        w.EmptyClipboard()
        w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
        w.CloseClipboard()
        return 0

    def send_qq_text(self, msg):
        qq = self.m_handle.hwnd
        if qq == 0:
            print("句柄为0")
            return -1

        SendQQ.set_text(msg)

        # 投递剪贴板消息到QQ窗体
        time.sleep(0.3)
        win32gui.ShowWindow(qq, 1)
        win32gui.SetForegroundWindow(qq)

        win32gui.SendMessage(qq, 258, 22, 2080193)
        win32gui.SendMessage(qq, 770, 0, 0)
        SendQQ.send_key()

        time.sleep(0.3)
        win32gui.ShowWindow(qq, 2)
        return 0

    def send_qq_bmp(self, image_path):
        qq = self.m_handle.hwnd
        if qq == 0:
            print("句柄为0")
            return -1
        #im = Image.open('new.jpg')
        #im.save('11.bmp')
        aString = ctypes.windll.user32.LoadImageW(0, image_path,
                                                  win32con.IMAGE_BITMAP, 0, 0,
                                                  win32con.LR_LOADFROMFILE)
        print(aString)
        SendQQ.set_image(aString)

        time.sleep(0.3)
        win32gui.ShowWindow(qq, 1)
        win32gui.SetForegroundWindow(qq)

        win32gui.SendMessage(qq, 258, 22, 2080193)
        win32gui.SendMessage(qq, 770, 0, 0)
        SendQQ.send_key()

        time.sleep(0.3)
        win32gui.ShowWindow(qq, 2)
        return 0

    @staticmethod
    def send_key():
        # pyuserinput 的 Keyboard
        key_board = Keyboard()
        # 发送消息的快捷键
        key_board.alt_s()
        return 0

    def get_text(self, name):
        re = Window.get_window(self.m_handle, None, name)
        if re != 0:
            print("找不到窗口:" + name)
            return ""
        else:
            print("窗口:" + name)

        win32gui.ShowWindow(self.m_handle.hwnd, 1)
        win32gui.SetForegroundWindow(self.m_handle.hwnd)
        time.sleep(0.3)

        re = Window.get_window(self.m_handle, None, name)
        if re != 0:
            print("找不到窗口:" + name)
            return ""
        else:
            print("窗口:" + name)

        center_x = (self.m_handle.right + self.m_handle.left) / 2
        center_y = (self.m_handle.bottom + self.m_handle.top) / 2
        mouse = Mouse()
        mouse.click(int(center_x), int(center_y))

        time.sleep(0.3)
        key_board = Keyboard()
        key_board.ctrl_A_C()

        time.sleep(0.3)
        win32gui.ShowWindow(self.m_handle.hwnd, 2)

        text = SendQQ.get_clipboard_text()
        cmd = SendQQ.get_last_cmd(text, name)
        return cmd

    @staticmethod
    def get_last_cmd(msg, name):
        # 按回车切割成list
        temp_list = msg.splitlines()
        list_len = len(temp_list)
        if list_len == 0:
            return ""

        # 如果最后一条消息是对方发的才取,否则返回空
        re = temp_list[list_len - 2]
        if re[:len(name)] == name:
            re = temp_list[list_len - 1]
        else:
            re = ''

        return re

    def send_jie_tu(self, handle=None):
        window_img = Window.jie_tu(handle)
        image_path = "temp/qqjietu.bmp"
        window_img.save(image_path)
        self.send_qq_bmp(image_path)
        return 0