├── .gitattributes ├── .gitignore ├── Doc ├── screenshot.jpg └── screenshot2.png ├── LICENSE ├── README.md └── yys ├── .idea ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── workspace.xml └── yys.iml ├── EncryptModule.py ├── RegisterKeyModule.py ├── Window.exe ├── Window.py ├── YuHunModule.py └── img ├── auto.jpg ├── end1.jpg ├── end2.jpg ├── jieshou1.jpg ├── jieshou2.jpg ├── jixu.jpg ├── queding.jpg ├── reject.jpg ├── tiaozhan.jpg ├── tili60.jpg └── tili80.jpg /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | 62 | # Flask stuff: 63 | instance/ 64 | .webassets-cache 65 | 66 | # Scrapy stuff: 67 | .scrapy 68 | 69 | # Sphinx documentation 70 | docs/_build/ 71 | 72 | # PyBuilder 73 | target/ 74 | 75 | # Jupyter Notebook 76 | .ipynb_checkpoints 77 | 78 | # IPython 79 | profile_default/ 80 | ipython_config.py 81 | 82 | # pyenv 83 | .python-version 84 | 85 | # pipenv 86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 88 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 89 | # install all needed dependencies. 90 | #Pipfile.lock 91 | 92 | # celery beat schedule file 93 | celerybeat-schedule 94 | 95 | # SageMath parsed files 96 | *.sage.py 97 | 98 | # Environments 99 | .env 100 | .venv 101 | env/ 102 | venv/ 103 | ENV/ 104 | env.bak/ 105 | venv.bak/ 106 | 107 | # Spyder project settings 108 | .spyderproject 109 | .spyproject 110 | 111 | # Rope project settings 112 | .ropeproject 113 | 114 | # mkdocs documentation 115 | /site 116 | 117 | # mypy 118 | .mypy_cache/ 119 | .dmypy.json 120 | dmypy.json 121 | 122 | # Pyre type checker 123 | .pyre/ 124 | -------------------------------------------------------------------------------- /Doc/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/Doc/screenshot.jpg -------------------------------------------------------------------------------- /Doc/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/Doc/screenshot2.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # yysScript 阴阳师护肝脚本 2 | 3 | 阴阳师脚本 支持御魂副本多开 觉得好用的话请点个star吧~ 4 | 5 | ## 注意事项 6 | 7 | 1. 支持任意安卓模拟器和官方PC端,任意分辨率(不要过小即可),在运行过程中不能遮挡游戏界面或手动移动鼠标(建议去干别的事或者开个电视剧在边上)。 8 | 2. 如果鼠标无法自动移动或者点击目标,可以用右键点击Window.exe,用管理员身份运行Windows.exe程序。 9 | 3. 如果游戏更新后修改了一些图片,可以手动截图替换掉img路径下的图片。 10 | 4. 只需要软件不需要源码研究的可以在[点击此处打开下载页面](https://github.com/li-zheng-hao/yysScript/releases)中下载压缩包解压即可用。 11 | 5. 有时候release页面中没有更新新的压缩包,可以之间在上面点fork,下载到本地后点击里面的Window.exe运行,这个程序保证是最新的(我自己使用的时候就是用这个,压缩包只是方便那些不用看代码或者看不懂的人)。 12 | 6. **如果在运行过程中发现有某个用于定位的图片检测不到,可能是分辨率的影响,可以自己将游戏调到经常用的分辨率大小后再自己根据img下面的图片自己截图替换掉,注意名字不能改变**。 13 | 14 | ## ✔2019年10月18日 更新 15 | 16 | 1. 修复了在win10下小概率点击显示桌面按钮的bug。 17 | 2. 日志输出框中改成了输出每轮开始的时间,可以自己计算一次消耗多少时间(PC端一天限制500次御魂副本,也就是2000体力) 18 | 19 | ## ⚡2019年10月12日 更新 20 | 21 | 1. 增加悬赏封印邀请拒绝功能。 22 | 2. 针对特定的点击需求(结算界面),增加点击的时间延迟及位置偏移,防止鬼使黑来信。(目前测试500体左右没发生啥事) 23 | 24 | ## v2.0版本更新 25 | 26 | 1. 大幅优化准确率和速度,目前测试双开无问题,理论上支持任意多个程序同时跑(一般不超过4个比较好)。 27 | 2. F4快捷键停止脚本(缺点就是焦点要在脚本程序上,否则无效)。 28 | 3. 将一些bug修复,修改脚本UI。 29 | 4. 增加日志功能,查看当前运行状态。 30 | 31 | ## 软件截图 32 | 33 | ![image](https://github.com/li-zheng-hao/yysscript/raw/master/Doc/screenshot.jpg) 34 | 35 | ![image](https://github.com/li-zheng-hao/yysscript/raw/master/Doc/screenshot2.png)
36 | -------------------------------------------------------------------------------- /yys/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /yys/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /yys/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /yys/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 33 | 34 | 35 | 36 | 37 | 56 | 57 | 58 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 1569566364406 91 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /yys/.idea/yys.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /yys/EncryptModule.py: -------------------------------------------------------------------------------- 1 | # 文件加密解密模块 2 | import json 3 | from pathlib import Path 4 | 5 | class EncryptUtil: 6 | 7 | @staticmethod 8 | def decrypt(encrypted: int, key_int: int) -> str: 9 | decrypted: int = encrypted ^ key_int 10 | length = (decrypted.bit_length() + 7) // 8 11 | decrypted_bytes: bytes = int.to_bytes(decrypted, length, 'big') 12 | return decrypted_bytes.decode() 13 | 14 | 15 | @staticmethod 16 | def encrypt_file(path: str, key_path=None, *, encoding='utf-8'): 17 | """ 18 | 文件加密 19 | :param path: 20 | :param key_path: 21 | :param encoding: 22 | :return: 23 | """ 24 | path = Path(path) 25 | cwd = path.cwd() / path.name.split('.')[0] 26 | path_encrypted = cwd / path.name 27 | if key_path is None: 28 | key_path = cwd / 'key' 29 | if not cwd.exists(): 30 | cwd.mkdir() 31 | path_encrypted.touch() 32 | key_path.touch() 33 | 34 | with path.open('rt', encoding=encoding) as f1, \ 35 | path_encrypted.open('wt', encoding=encoding) as f2, \ 36 | key_path.open('wt', encoding=encoding) as f3: 37 | encrypted, key = EncryptUtil.encrypt(f1.read()) 38 | json.dump(encrypted, f2) 39 | json.dump(key, f3) 40 | 41 | @staticmethod 42 | def decrypt_file(path_encrypted: str, key_path=None, *, encoding='utf-8'): 43 | """ 44 | 文件解密 45 | :param path_encrypted: 46 | :param key_path: 47 | :param encoding: 48 | :return: 49 | """ 50 | path_encrypted = Path(path_encrypted) 51 | cwd = path_encrypted.cwd() 52 | path_decrypted = cwd / 'decrypted' 53 | if not path_decrypted.exists(): 54 | path_decrypted.mkdir() 55 | path_decrypted /= path_encrypted.name 56 | path_decrypted.touch() 57 | if key_path is None: 58 | key_path = cwd / 'key' 59 | with path_encrypted.open('rt', encoding=encoding) as f1, \ 60 | key_path.open('rt', encoding=encoding) as f2, \ 61 | path_decrypted.open('wt', encoding=encoding) as f3: 62 | decrypted = EncryptUtil.decrypt(json.load(f1), json.load(f2)) 63 | #后期更改,不需要进行读入 64 | f3.write(decrypted) -------------------------------------------------------------------------------- /yys/RegisterKeyModule.py: -------------------------------------------------------------------------------- 1 | # 生成激活码模块 2 | 3 | class RegisterKeyUtil: 4 | def ValidateUserKey(userkey: str) -> bool: 5 | # todo 6 | pass 7 | 8 | def CreateUserKey(path: str) -> bool: 9 | # todo 10 | pass 11 | -------------------------------------------------------------------------------- /yys/Window.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/Window.exe -------------------------------------------------------------------------------- /yys/Window.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | # 窗体模块 3 | import ctypes 4 | import inspect 5 | import threading 6 | import time 7 | import tkinter as tk 8 | from concurrent.futures import thread 9 | import tkinter 10 | from tkinter import * 11 | from tkinter import scrolledtext, messagebox 12 | 13 | from YuHunModule import YuHun 14 | 15 | MSG = [] 16 | tasks = [] 17 | NeedCloseGame = False 18 | NeedCloseSystem = False 19 | 20 | 21 | def YuhunTwo(LogUI, NeedCloseGame, NeedCloseSystem): 22 | """ 23 | 御魂副本双开 24 | :return: 25 | """ 26 | messagebox.showinfo('提示', '请确保两个帐号都已经进入组队房间并且阵容锁定') 27 | fun = YuHun() 28 | t = threading.Thread(target=fun.Run, args=(LogUI, NeedCloseGame, NeedCloseSystem)) 29 | t.start() 30 | tasks.append(fun) 31 | 32 | 33 | def StopAll(LogUI): 34 | """ 35 | 36 | :return: 37 | """ 38 | try: 39 | global tasks 40 | for i in tasks: 41 | i.Terminate() 42 | tasks = [] 43 | if LogUI is not None: 44 | LogUI.insert(END, 45 | time.strftime('%Y-%m-%d %H:%M:%S', 46 | time.localtime(time.time())) + ' 脚本停止\n') 47 | # LogUI.insert(END, '全部动作停止\n') 48 | LogUI.see(END) 49 | except Exception as e: 50 | if LogUI is not None: 51 | tasks = [] 52 | LogUI.insert(END, 53 | time.strftime('%Y-%m-%d %H:%M:%S', 54 | time.localtime(time.time())) + ' 脚本停止异常,可能已经停止,请重启再试\n') 55 | LogUI.see(END) 56 | print(e) 57 | 58 | 59 | def Closing(app): 60 | try: 61 | if messagebox.askokcancel("Quit", "Do you want to quit?"): 62 | StopAll(None) 63 | app.destroy() 64 | except Exception: 65 | sys.exit(-1) 66 | 67 | 68 | def ShortCut(event): 69 | """ 70 | 按f4 停止脚本 71 | :param event: 72 | :return: 73 | """ 74 | # print("event.char =", event.char) 75 | # print("event.keycode =", event.keycode) 76 | # F4停止 77 | global app 78 | if event.keycode == 115: 79 | StopAll(Window.LogUI) 80 | 81 | 82 | def ChangeEndActionWithGame(): 83 | """ 84 | 选择是否体力用完关闭游戏 85 | :return: 86 | """ 87 | global NeedCloseGame 88 | NeedCloseGame = not NeedCloseGame 89 | global tasks 90 | for i in tasks: 91 | i.NeedCloseGame = NeedCloseGame 92 | print('NeedCloseGame', str(NeedCloseGame)) 93 | 94 | 95 | def ChangeEndActionWithSystem(): 96 | """ 97 | 选择是否体力用完是否关机 98 | :return: 99 | """ 100 | global NeedCloseSystem 101 | NeedCloseSystem = not NeedCloseSystem 102 | global tasks 103 | for i in tasks: 104 | i.NeedCloseSystem = NeedCloseSystem 105 | print('NeedCloseSystem', NeedCloseSystem) 106 | 107 | 108 | class Window: 109 | def __init__(self): 110 | self.initWidgets() 111 | 112 | def initWidgets(self): 113 | self.app = tk.Tk() # 根窗口的实例(root窗口) 114 | self.app.geometry('600x200') 115 | self.app.resizable(0, 0) # 阻止Python GUI的大小调整 116 | frame1 = Frame(self.app, padx=20) 117 | frame1.pack(side=LEFT, fill=BOTH) 118 | t1 = tk.Label(frame1, text='护肝脚本', font=("华文行楷", 22), borderwidth=2).pack(side=TOP, fill=X, expand=YES) 119 | 120 | frame2 = Frame(self.app) 121 | t1 = tk.Label(frame2, text='日志', borderwidth=2, font=('微软雅黑', 10), height=1).pack(side=TOP, fill=X, expand=YES) 122 | t3 = scrolledtext.ScrolledText(frame2, font=('微软雅黑', 10)) 123 | t3.pack(side=TOP, fill=X, expand=YES) 124 | frame2.pack(side=RIGHT, fill=BOTH, expand=YES) 125 | Button(frame1, command=lambda: YuhunTwo(t3, NeedCloseGame, NeedCloseSystem), text='自动御魂副本', width=20).pack( 126 | side=TOP, expand=YES) 127 | Checkbutton(frame1, text='体力用完自动关闭游戏', command=ChangeEndActionWithGame).pack(side=TOP, anchor='w') 128 | Checkbutton(frame1, text='体力用完自动关机', command=ChangeEndActionWithSystem).pack(side=TOP, anchor='w') 129 | Button(frame1, command=lambda: StopAll(t3), text='停止', width=20).pack(side=TOP, expand=YES) 130 | 131 | self.app.protocol("WM_DELETE_WINDOW", lambda: Closing(self.app)) 132 | Window.LogUI = t3 133 | self.app.bind("", ShortCut) 134 | self.app.mainloop() # 窗口的主事件循环,必须的。 135 | 136 | 137 | if __name__ == '__main__': 138 | app = Window() 139 | -------------------------------------------------------------------------------- /yys/YuHunModule.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import datetime 3 | import logging 4 | import os 5 | import random 6 | import time 7 | from tkinter import END 8 | 9 | import cv2 10 | import numpy 11 | import numpy as np 12 | import pyautogui 13 | from PIL import ImageGrab 14 | from matplotlib import pyplot as plt 15 | 16 | pyautogui.FAILSAFE = False 17 | logging.basicConfig(format="%(asctime)s :%(levelname)s:%(message)s", datefmt="%d-%M-%Y %H:%M:%S", level=logging.DEBUG) 18 | # 初始化SIFT探测器 19 | SIFT = cv2.xfeatures2d.SIFT_create() 20 | 21 | 22 | def ComputeScreenShot(screenShot): 23 | """ 24 | 由于屏幕分辨率高,计算耗时,这里优化一下 25 | :return: 26 | """ 27 | kp2, des2 = SIFT.detectAndCompute(screenShot, None) 28 | return kp2, des2 29 | 30 | 31 | def GetLocation(target, kp2, des2): 32 | """ 33 | 获取目标图像在截图中的位置 34 | :param target: 35 | :param screenShot: 36 | :return: 返回坐标(x,y) 与opencv坐标系对应 37 | """ 38 | MIN_MATCH_COUNT = 10 39 | img1 = target # cv2.cvtColor(target,cv2.COLOR_BGR2GRAY)# 查询图片 40 | # img2 = screenShot 41 | # img2 = cv2.cvtColor(screenShot, cv2.COLOR_BGR2GRAY) # 训练图片 42 | # img2 = cv2.resize(img2, dsize=None, fx=0.5, fy=0.5, interpolation=cv2.INTER_NEAREST) 43 | # 用SIFT找到关键点和描述符 44 | 45 | kp1, des1 = SIFT.detectAndCompute(img1, None) 46 | 47 | FLANN_INDEX_KDTREE = 0 48 | index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=4) 49 | search_params = dict(checks=50) 50 | 51 | flann = cv2.FlannBasedMatcher(index_params, search_params) 52 | matches = flann.knnMatch(des1, des2, k=2) 53 | good = [] 54 | for m, n in matches: 55 | if m.distance < 0.7 * n.distance: 56 | good.append(m) 57 | if len(good) > MIN_MATCH_COUNT: 58 | src_pts = np.float32([kp1[m.queryIdx].pt for m in good]).reshape(-1, 1, 2) 59 | dst_pts = np.float32([kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2) 60 | M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0) 61 | matchesMask = mask.ravel().tolist() 62 | h, w = img1.shape 63 | pts = np.float32([[0, 0], [0, h - 1], [w - 1, h - 1], [w - 1, 0]]).reshape(-1, 1, 2) 64 | if M is not None: 65 | dst = cv2.perspectiveTransform(pts, M) 66 | arr = np.int32(dst) # 67 | midPosArr = arr[0] + (arr[2] - arr[0]) // 2 68 | midPos = (midPosArr[0][0], midPosArr[0][1]) 69 | # show=cv2.circle(img2,midPos,30,(255,255,255),thickness=5) 70 | # cv2.imshow('s',show) 71 | # cv2.waitKey() 72 | # cv2.destroyAllWindows() 73 | return midPos 74 | else: 75 | return None 76 | else: 77 | return None 78 | 79 | 80 | def CheatPos(originPos, factor=5): 81 | """ 82 | 对原始点击坐标进行随机偏移,防止封号 83 | :param originPos:原始坐标 84 | :return: 85 | """ 86 | x, y = random.randint(-factor, factor), random.randint(-factor, factor) 87 | newPos = (originPos[0] + x, originPos[1] + y) 88 | return newPos 89 | 90 | 91 | def Click(targetPosition): 92 | """ 93 | 点击屏幕上的某个点 94 | :param targetPosition: 95 | :return: 96 | """ 97 | if targetPosition is None: 98 | print('未检测到目标') 99 | else: 100 | 101 | pyautogui.moveTo(targetPosition, duration=0.20) 102 | pyautogui.click() 103 | time.sleep(random.randint(500, 1000) / 1000) 104 | 105 | # time.sleep(random.randint(100, 150) / 1000) 106 | 107 | 108 | def loadImgs(): 109 | """ 110 | 加载所有需要检测的目标图像 111 | :return: 112 | """ 113 | obj = {} 114 | path = os.getcwd() + '/img' 115 | file_list = os.listdir(path) 116 | 117 | for file in file_list: 118 | name = file.split('.')[0] 119 | file_path = path + '/' + file 120 | a = cv2.imread(file_path, 0) 121 | obj[name] = a 122 | 123 | return obj 124 | 125 | 126 | def GetScreenShot(): 127 | """ 128 | 获取屏幕截图 129 | :return: 130 | """ 131 | screen = ImageGrab.grab() 132 | # screen.save('screen.jpg') 133 | # screen = cv2.imread('screen.jpg') 134 | screen = cv2.cvtColor(numpy.asarray(screen), cv2.COLOR_RGB2BGR) 135 | logging.info('截屏成功') 136 | return screen 137 | 138 | 139 | class YuHun(): 140 | def __init__(self): 141 | self._flag = False 142 | self.NeedCloseGame=False 143 | self.NeedCloseSystem=False 144 | 145 | def Run(self, LogUI, NeedCloseGame, NeedCloseSystem): 146 | imgs = loadImgs() 147 | LogUI.insert(END, 148 | time.strftime('%Y-%m-%d %H:%M:%S ', 149 | time.localtime(time.time())) + '开始挑战\n') 150 | Count = 1 151 | while self._flag is not True: 152 | logging.debug('开始挑战') 153 | screen = GetScreenShot() 154 | WindowShape = screen.shape 155 | result = [] 156 | 157 | # 为了优化速度,把计算屏幕截图的特征提取出来,避免重复运算 158 | kp2, des2 = ComputeScreenShot(screen) 159 | for i in ['tili60', 'tili80', 'auto', 'jieshou2', 'jieshou1', 'end1', 'end2', 'reject', 'queding', 160 | 'tiaozhan']: 161 | obj = imgs[i] 162 | # begin = time.clock() 163 | pos = GetLocation(obj, kp2, des2) 164 | # logging.debug('检测结算目标图像') 165 | # print(time.clock()-begin) 166 | if pos is not None: 167 | if i == 'tili60' or i == 'tili80': 168 | print('window.py', NeedCloseSystem) 169 | if self.NeedCloseSystem: 170 | print('log') 171 | os.system('shutdown -s -t 60') 172 | return 173 | if not self.NeedCloseGame: 174 | # 需要手动关闭游戏 175 | LogUI.insert(END, 176 | time.strftime('%Y-%m-%d %H:%M:%S ', 177 | time.localtime(time.time())) + '体力用完,需要手动关闭加成或游戏\n') 178 | return 179 | # 结束进程 180 | hasProcess = True 181 | while hasProcess: 182 | if 'onmyoji' in os.popen('tasklist /FI "IMAGENAME eq onmyoji.exe"').read(): 183 | os.system('TASKKILL /F /IM onmyoji.exe') 184 | hasProcess = True 185 | else: 186 | hasProcess = False 187 | # 线程结束返回 188 | return 189 | elif i == 'end1': 190 | time.sleep(random.randint(300, 800) / 1000) 191 | pos = CheatPos(pos, 50) 192 | elif i == 'end2': 193 | newPos = (pos[0] + 80, pos[1] + 80) 194 | pos = CheatPos(newPos, 5) 195 | elif i == 'tiaozhan': 196 | LogUI.insert(END, 197 | time.strftime('%Y-%m-%d %H:%M:%S ', 198 | time.localtime(time.time())) + '第' + str(Count) + '轮开始\n') 199 | Count += 1 200 | elif i == 'reject': 201 | pos = CheatPos(pos, 3) 202 | else: 203 | pos = CheatPos(pos, 10) 204 | result.append(pos) 205 | 206 | LogUI.see(END) 207 | else: 208 | result.append(None) 209 | # 开始检查结果 210 | for i in result: 211 | if i is not None: 212 | print(WindowShape[1] * 0.06) 213 | print(WindowShape[0] * 0.96) 214 | if i[0] < WindowShape[1] * 0.06 or i[1] > WindowShape[0] * 0.96: 215 | continue 216 | else: 217 | Click(i) 218 | if len(LogUI.get('1.0', 'end-1c')) > 6000: 219 | LogUI.delete(1.0, END) # 使用 delete 220 | LogUI.insert(END, ' 清空日志\n') 221 | LogUI.see(END) 222 | 223 | def Terminate(self): 224 | self._flag = True 225 | 226 | 227 | # def YuHunTwoWindow(LogUI, NeedCloseGame, NeedCloseSystem): 228 | # """ 229 | # 自动御魂,双开模式 230 | # """ 231 | # imgs = loadImgs() 232 | # LogUI.insert(END, 233 | # time.strftime('%Y-%m-%d %H:%M:%S ', 234 | # time.localtime(time.time())) + '开始挑战\n') 235 | # Count = 1 236 | # while True: 237 | # 238 | # logging.debug('开始挑战') 239 | # screen = GetScreenShot() 240 | # WindowShape = screen.shape 241 | # result = [] 242 | # 243 | # # 为了优化速度,把计算屏幕截图的特征提取出来,避免重复运算 244 | # kp2, des2 = ComputeScreenShot(screen) 245 | # for i in ['tili60', 'tili80', 'auto', 'jieshou2', 'jieshou1', 'end1', 'end2', 'reject', 'queding', 'tiaozhan']: 246 | # obj = imgs[i] 247 | # # begin = time.clock() 248 | # pos = GetLocation(obj, kp2, des2) 249 | # # logging.debug('检测结算目标图像') 250 | # # print(time.clock()-begin) 251 | # if pos is not None: 252 | # if i == 'tili60' or i == 'tili80': 253 | # print('window.py', NeedCloseSystem) 254 | # if NeedCloseSystem: 255 | # print('log') 256 | # os.system('shutdown -s -t 60') 257 | # return 258 | # if not NeedCloseGame: 259 | # # print('体力用完,需要手动关闭加成或游戏') 260 | # LogUI.insert(END, 261 | # time.strftime('%Y-%m-%d %H:%M:%S ', 262 | # time.localtime(time.time())) + '体力用完,需要手动关闭加成或游戏\n') 263 | # return 264 | # # 结束进程 265 | # hasProcess = True 266 | # while hasProcess: 267 | # if 'onmyoji' in os.popen('tasklist /FI "IMAGENAME eq onmyoji.exe"').read(): 268 | # os.system('TASKKILL /F /IM onmyoji.exe') 269 | # hasProcess = True 270 | # else: 271 | # hasProcess = False 272 | # # 线程结束返回 273 | # return 274 | # elif i == 'end1': 275 | # time.sleep(random.randint(300, 800) / 1000) 276 | # pos = CheatPos(pos, 50) 277 | # elif i == 'end2': 278 | # newPos = (pos[0] + 80, pos[1] + 80) 279 | # pos = CheatPos(newPos, 5) 280 | # elif i == 'tiaozhan': 281 | # LogUI.insert(END, 282 | # time.strftime('%Y-%m-%d %H:%M:%S ', 283 | # time.localtime(time.time())) + '第' + str(Count) + '轮开始\n') 284 | # Count += 1 285 | # elif i == 'reject': 286 | # pos = CheatPos(pos, 3) 287 | # else: 288 | # pos = CheatPos(pos, 10) 289 | # result.append(pos) 290 | # 291 | # LogUI.see(END) 292 | # else: 293 | # result.append(None) 294 | # # 开始检查结果 295 | # for i in result: 296 | # if i is not None: 297 | # print(WindowShape[1] * 0.06) 298 | # print(WindowShape[0] * 0.96) 299 | # if i[0] < WindowShape[1] * 0.06 or i[1] > WindowShape[0] * 0.96: 300 | # continue 301 | # else: 302 | # Click(i) 303 | # if len(LogUI.get('1.0', 'end-1c')) > 6000: 304 | # LogUI.delete(1.0, END) # 使用 delete 305 | # LogUI.insert(END, ' 清空日志\n') 306 | # LogUI.see(END) 307 | 308 | 309 | if __name__ == '__main__': 310 | pass 311 | -------------------------------------------------------------------------------- /yys/img/auto.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/auto.jpg -------------------------------------------------------------------------------- /yys/img/end1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/end1.jpg -------------------------------------------------------------------------------- /yys/img/end2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/end2.jpg -------------------------------------------------------------------------------- /yys/img/jieshou1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/jieshou1.jpg -------------------------------------------------------------------------------- /yys/img/jieshou2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/jieshou2.jpg -------------------------------------------------------------------------------- /yys/img/jixu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/jixu.jpg -------------------------------------------------------------------------------- /yys/img/queding.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/queding.jpg -------------------------------------------------------------------------------- /yys/img/reject.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/reject.jpg -------------------------------------------------------------------------------- /yys/img/tiaozhan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/tiaozhan.jpg -------------------------------------------------------------------------------- /yys/img/tili60.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/tili60.jpg -------------------------------------------------------------------------------- /yys/img/tili80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/li-zheng-hao/yysScript/079101f57fb1a64b871924c988760d9e74063a71/yys/img/tili80.jpg --------------------------------------------------------------------------------