├── .gitignore ├── __pycache__ ├── gaming_func.cpython-310.pyc ├── notice_func.cpython-310.pyc └── window_operate.cpython-310.pyc ├── README.md ├── notice_func.py ├── main.spec ├── main.py ├── window_operate.py ├── gaming_func.py └── test.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | .idea/ 4 | __pycache__/ 5 | logs/ 6 | venv/ 7 | *.pyc 8 | *.pyo 9 | test.py 10 | *.exe -------------------------------------------------------------------------------- /__pycache__/gaming_func.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Amovement/SaltedFishBot/HEAD/__pycache__/gaming_func.cpython-310.pyc -------------------------------------------------------------------------------- /__pycache__/notice_func.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Amovement/SaltedFishBot/HEAD/__pycache__/notice_func.cpython-310.pyc -------------------------------------------------------------------------------- /__pycache__/window_operate.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Amovement/SaltedFishBot/HEAD/__pycache__/window_operate.cpython-310.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 咸鱼之王pc端 学习脚本 2 | ### 运行时 3 | [![pPdks3t.png](https://s1.ax1x.com/2023/08/29/pPdks3t.png)](https://imgse.com/i/pPdks3t) 4 | 5 | ### 目前功能 6 | #### 0. 显示/隐藏 7 | 后台挂机 8 | 9 | #### 1. 离线奖励 10 | 每隔两小时领取离线奖励,会主动升级奖励 11 | 12 | #### 2. 咸将塔 13 | 每隔两小时会自动咸将塔战斗 14 | 15 | 16 | ### 参考项目 17 | https://github.com/Frica01/GameAssistant 18 | -------------------------------------------------------------------------------- /notice_func.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Author: Amove 3 | 4 | def print_notice(): 5 | print("-----------------") 6 | print("cmd input:") 7 | 8 | def print_help(): 9 | print("-----------------") 10 | print("1. 显示窗口") 11 | print("2. 隐藏窗口") 12 | print("shoucai. 收离线奖励") 13 | print("tower. 咸将塔") 14 | print("help. 帮助") 15 | print("exit. 退出") 16 | print("-----------------") -------------------------------------------------------------------------------- /main.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | 4 | block_cipher = None 5 | 6 | 7 | a = Analysis( 8 | ['main.py'], 9 | pathex=[], 10 | binaries=[], 11 | datas=[], 12 | hiddenimports=[], 13 | hookspath=[], 14 | hooksconfig={}, 15 | runtime_hooks=[], 16 | excludes=[], 17 | win_no_prefer_redirects=False, 18 | win_private_assemblies=False, 19 | cipher=block_cipher, 20 | noarchive=False, 21 | ) 22 | pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) 23 | 24 | exe = EXE( 25 | pyz, 26 | a.scripts, 27 | a.binaries, 28 | a.zipfiles, 29 | a.datas, 30 | [], 31 | name='main', 32 | debug=False, 33 | bootloader_ignore_signals=False, 34 | strip=False, 35 | upx=True, 36 | upx_exclude=[], 37 | runtime_tmpdir=None, 38 | console=True, 39 | disable_windowed_traceback=False, 40 | argv_emulation=False, 41 | target_arch=None, 42 | codesign_identity=None, 43 | entitlements_file=None, 44 | ) 45 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Author: Amove 3 | # vision 1.1 zero 修改支持高分辨 4 | 5 | from window_operate import * 6 | from gaming_func import * 7 | from notice_func import * 8 | import sys,time,os 9 | import threading 10 | 11 | 12 | if __name__ == '__main__': 13 | # 初始化 14 | hwnd = get_window_handle(title="咸鱼之王") 15 | #获取窗口 大小w,h 16 | rect = win32gui.GetWindowRect(hwnd) 17 | x,y=rect[0],rect[1] 18 | w,h=rect[2] - x,rect[3] - y 19 | 20 | if hwnd == 0: 21 | print("游戏未启动,退出...") 22 | time.sleep(3) 23 | os._exit(1) 24 | print_help() 25 | print("Start...tap help for more details.") 26 | 27 | # 领取离线奖励的线程 28 | thread1 = threading.Thread(target=shoucai_rountin_long, args=(hwnd,)) 29 | thread1.start() 30 | 31 | # 爬塔的线程 32 | thread2 = threading.Thread(target=fuben_tower_rountin, args=(hwnd,)) 33 | thread2.start() 34 | 35 | time.sleep(1) 36 | # 主函数 37 | while True: 38 | print_notice() 39 | cmd_input = input() 40 | 41 | if cmd_input == "1": 42 | show_window(hwnd) 43 | elif cmd_input == "2": 44 | hide_window(hwnd) 45 | elif cmd_input == "help": 46 | print_help() 47 | elif cmd_input == "shoucai": 48 | shoucai(hwnd,h,w) 49 | elif cmd_input == "tower": 50 | fuben_tower(hwnd,h,w) 51 | elif cmd_input == "daily": 52 | daily_test(hwnd,h,w) 53 | elif cmd_input == "exit": 54 | print("Bye!") 55 | os._exit(1) -------------------------------------------------------------------------------- /window_operate.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Author: Amove 3 | 4 | import win32gui 5 | import win32con 6 | import win32api 7 | import time 8 | import win32com.client 9 | 10 | 11 | def get_window_handle(class_name=None, title=None): 12 | """ 13 | 通过类名和标题查找窗口句柄. 14 | 15 | Args: 16 | class_name(str|None):窗口的类名. 默认为None. 17 | title(str|None):窗口的标题. 默认为None. 18 | 19 | Returns: 20 | int: 返回找到的窗口句柄,如果没有找到则返回0. 21 | """ 22 | return win32gui.FindWindow(class_name, title) 23 | 24 | 25 | def set_top_window(hwnd): 26 | """ 27 | 窗口置顶 28 | """ 29 | shell = win32com.client.Dispatch("WScript.Shell") 30 | shell.SendKeys('%') 31 | win32gui.SetForegroundWindow(hwnd) 32 | 33 | 34 | def hide_window(hwnd): 35 | """ 36 | 隐藏窗口 37 | 38 | Args: 39 | title(str|None):窗口的标题. 默认为None. 40 | 41 | Returns: 42 | None 43 | """ 44 | if hwnd == 0: 45 | return False 46 | set_top_window(hwnd=hwnd) 47 | win32gui.ShowWindow(hwnd, win32con.SW_HIDE) 48 | return True 49 | 50 | 51 | def show_window(hwnd): 52 | """ 53 | 显示窗口 54 | 55 | Args: 56 | title(str|None):窗口的标题. 默认为None. 57 | 58 | Returns: 59 | None 60 | """ 61 | if hwnd == 0: 62 | return False 63 | win32gui.ShowWindow(hwnd, win32con.SW_SHOW) 64 | set_top_window(hwnd=hwnd) 65 | return True 66 | 67 | # 后台点击操作 68 | def perform_background_click(hwnd, x, y,cnt=1): 69 | lParam = win32api.MAKELONG(int(x), int(y)) 70 | count = 0 71 | while True: 72 | if count>=cnt: 73 | break 74 | time.sleep(0.2) 75 | win32api.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam) 76 | win32api.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lParam) 77 | count+=1 78 | 79 | # 后台移动操作 80 | def perform_background_move(hwnd, x, y,cnt=1): 81 | lParam = win32api.MAKELONG(int(x), int(y)) 82 | lParam1 = win32api.MAKELONG(int(x)+100, int(y)) 83 | count = 0 84 | while True: 85 | if count>=cnt: 86 | break 87 | time.sleep(0.2) 88 | win32api.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam) 89 | win32api.SendMessage(hwnd, win32con.WM_MOUSEMOVE, win32con.MK_LBUTTON, lParam1) 90 | win32api.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0) 91 | count+=1 -------------------------------------------------------------------------------- /gaming_func.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Author: Amove 3 | # vision 1.1 zero 修改支持高分辨 4 | 5 | import time 6 | import datetime 7 | from window_operate import * 8 | import threading 9 | 10 | # 创建互斥锁 11 | mutex = threading.Lock() 12 | def fuben_tower_rountin(hwnd): 13 | print("咸将塔线程已上线...",datetime.datetime.now()) 14 | while True: 15 | print("咸将塔线程心跳...",datetime.datetime.now()) 16 | time.sleep(60*60*3) # 三小时 17 | with mutex: # 获取互斥锁 18 | fuben_tower(hwnd) 19 | 20 | def shoucai_rountin_long(hwnd): 21 | print("收菜线程已上线...",datetime.datetime.now()) 22 | while True: 23 | print("收菜线程心跳...",datetime.datetime.now()) 24 | time.sleep(60*60*10) # 两小时 25 | with mutex: # 获取互斥锁 26 | shoucai(hwnd) 27 | 28 | #为了黑市活动设置短时间的 29 | def shoucai_rountin_short(hwnd): 30 | print("收菜线程已上线...",datetime.datetime.now()) 31 | while True: 32 | print("收菜线程心跳...",datetime.datetime.now()) 33 | time.sleep(60*60*2) # 两小时 34 | with mutex: # 获取互斥锁 35 | shoucai(hwnd) 36 | 37 | 38 | def shoucai(hwnd,h,w): 39 | time.sleep(1.5) 40 | # perform_background_move(hwnd,0.35*w,0.86*h,3) #划开锁屏(无法保证在首页) 41 | time.sleep(2) 42 | # 43/450 345/844 43 | perform_background_click(hwnd,0.0856*w,0.408*h,) # 收益按钮 44 | time.sleep(0.7) 45 | # 303/450 676/844 46 | perform_background_click(hwnd,0.67*w,0.8*h,5) # 升级按钮 47 | time.sleep(0.7) 48 | # 154/450 669/844 49 | perform_background_click(hwnd,0.34*w,0.792*h) # 领奖励按钮 50 | time.sleep(1.5) 51 | 52 | 53 | 54 | def fuben_tower(hwnd,h,w): 55 | time.sleep(1.5) 56 | # perform_background_move(hwnd,0.35*w,0.86*w,3) #划开锁屏(无法保证在首页) 57 | time.sleep(0.7) 58 | #413/450 795/844 59 | perform_background_click(hwnd,0.917*w,0.942*h) # 副本按钮 60 | time.sleep(2) 61 | #225/450 233/844 62 | perform_background_click(hwnd,0.3*w,0.276*h) # tower 按钮 63 | time.sleep(2) 64 | 65 | for i in range(0,10): 66 | #238/450 788/844 67 | perform_background_click(hwnd,0.529*w,0.934*h) # 挑战按钮 68 | time.sleep(1) 69 | #51/450 717/844 70 | perform_background_click(hwnd,0.11*w,0.849*h,3) # 跳过按钮 71 | time.sleep(4) 72 | 73 | time.sleep(1.5) 74 | #39/450 807/844 75 | perform_background_click(hwnd,0.0867*w,0.956*h,2) # 退出按钮 76 | time.sleep(1) 77 | #230/450 792/844 78 | perform_background_click(hwnd,0.511*w,0.938*h,2) # 返回案板首页 79 | time.sleep(5) 80 | 81 | def daily_test(hwnd,h,w): 82 | show_window(hwnd) 83 | time.sleep(1.5) 84 | # perform_background_move(hwnd,0.35*w,0.86*w,3) #划开锁屏(无法保证在首页) 85 | # time.sleep(1.5) 86 | #413/450 795/844 87 | perform_background_click(hwnd,0.917*w,0.942*h) # 副本按钮 88 | time.sleep(1) 89 | #225/450 233/844 90 | perform_background_click(hwnd,0.3*w,0.476*h) # 咸王考验按钮 91 | time.sleep(1) 92 | 93 | perform_background_click(hwnd,0.511*w,0.908*h,1) # 点击挑战按钮 94 | time.sleep(1) 95 | perform_background_click(hwnd,0.11*w,0.849*h,2) # 跳过按钮 96 | time.sleep(1) 97 | perform_background_click(hwnd,0.511*w,0.758*h,) # 点击确认 98 | time.sleep(1) 99 | perform_background_click(hwnd,0.0867*w,0.956*h,2) # 退出按钮 100 | time.sleep(1) 101 | #230/450 792/844 102 | perform_background_click(hwnd,0.511*w,0.938*h,2) # 返回案板首页 103 | time.sleep(5) 104 | 105 | -------------------------------------------------------------------------------- /test.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 8, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "-----------------\n", 13 | "1. 显示窗口\n", 14 | "2. 隐藏窗口\n", 15 | "shoucai. 收离线奖励\n", 16 | "tower. 咸将塔\n", 17 | "help. 帮助\n", 18 | "exit. 退出\n", 19 | "-----------------\n", 20 | "Start...tap help for more details.\n", 21 | "978 138\n", 22 | "905 1674\n", 23 | "603 1116\n" 24 | ] 25 | } 26 | ], 27 | "source": [ 28 | "from window_operate import *\n", 29 | "from gaming_func import *\n", 30 | "from notice_func import *\n", 31 | "import sys,time,os\n", 32 | "import threading\n", 33 | "\n", 34 | "from ctypes import *\n", 35 | "from ctypes.wintypes import *\n", 36 | "\n", 37 | "def get_current_size(hwnd):\n", 38 | " try:\n", 39 | " f = ctypes.windll.dwmapi.DwmGetWindowAttribute\n", 40 | " except WindowsError:\n", 41 | " f = None\n", 42 | " if f:\n", 43 | " rect = ctypes.wintypes.RECT()\n", 44 | " DWMWA_EXTENDED_FRAME_BOUNDS = 9\n", 45 | " f(ctypes.wintypes.HWND(hwnd),\n", 46 | " ctypes.wintypes.DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),\n", 47 | " ctypes.byref(rect),\n", 48 | " ctypes.sizeof(rect)\n", 49 | " )\n", 50 | " size = (rect.right - rect.left, rect.bottom - rect.top) \n", 51 | " return size\n", 52 | "\n", 53 | "hwnd = get_window_handle(title=\"咸鱼之王\")\n", 54 | "if hwnd == 0:\n", 55 | " print(\"游戏未启动,退出...\")\n", 56 | " time.sleep(3)\n", 57 | " os._exit(1)\n", 58 | "print_help()\n", 59 | "print(\"Start...tap help for more details.\")\n", 60 | "w1,h1=get_current_size(hwnd)\n", 61 | "rect = win32gui.GetWindowRect(hwnd)\n", 62 | "x,y=rect[0],rect[1]\n", 63 | "print(x,y)\n", 64 | "w,h=rect[2] - x,rect[3] - y\n", 65 | "print(w1,h1)\n", 66 | "print(w,h)" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 4, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "name": "stdout", 76 | "output_type": "stream", 77 | "text": [ 78 | "-----------------\n", 79 | "1. 显示窗口\n", 80 | "2. 隐藏窗口\n", 81 | "shoucai. 收离线奖励\n", 82 | "tower. 咸将塔\n", 83 | "help. 帮助\n", 84 | "exit. 退出\n", 85 | "-----------------\n", 86 | "Start...tap help for more details.\n", 87 | "24 9\n", 88 | "675 1266\n", 89 | "450 844\n" 90 | ] 91 | } 92 | ], 93 | "source": [ 94 | "from window_operate import *\n", 95 | "from gaming_func import *\n", 96 | "from notice_func import *\n", 97 | "import sys,time,os\n", 98 | "import threading\n", 99 | "\n", 100 | "from ctypes import *\n", 101 | "from ctypes.wintypes import *\n", 102 | "\n", 103 | "def get_current_size(hwnd):\n", 104 | " try:\n", 105 | " f = ctypes.windll.dwmapi.DwmGetWindowAttribute\n", 106 | " except WindowsError:\n", 107 | " f = None\n", 108 | " if f:\n", 109 | " rect = ctypes.wintypes.RECT()\n", 110 | " DWMWA_EXTENDED_FRAME_BOUNDS = 9\n", 111 | " f(ctypes.wintypes.HWND(hwnd),\n", 112 | " ctypes.wintypes.DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),\n", 113 | " ctypes.byref(rect),\n", 114 | " ctypes.sizeof(rect)\n", 115 | " )\n", 116 | " size = (rect.right - rect.left, rect.bottom - rect.top) \n", 117 | " return size\n", 118 | "\n", 119 | "hwnd = get_window_handle(title=\"咸鱼之王\")\n", 120 | "if hwnd == 0:\n", 121 | " print(\"游戏未启动,退出...\")\n", 122 | " time.sleep(3)\n", 123 | " os._exit(1)\n", 124 | "print_help()\n", 125 | "print(\"Start...tap help for more details.\")\n", 126 | "w1,h1=get_current_size(hwnd)\n", 127 | "rect = win32gui.GetWindowRect(hwnd)\n", 128 | "x,y=rect[0],rect[1]\n", 129 | "print(x,y)\n", 130 | "w,h=rect[2] - x,rect[3] - y\n", 131 | "print(w1,h1)\n", 132 | "print(w,h)" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": null, 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "x,y=rect[0],rect[1]\n", 142 | "w,h=rect[2] - x,rect[3] - y" 143 | ] 144 | } 145 | ], 146 | "metadata": { 147 | "kernelspec": { 148 | "display_name": "stable_diffusion", 149 | "language": "python", 150 | "name": "python3" 151 | }, 152 | "language_info": { 153 | "codemirror_mode": { 154 | "name": "ipython", 155 | "version": 3 156 | }, 157 | "file_extension": ".py", 158 | "mimetype": "text/x-python", 159 | "name": "python", 160 | "nbconvert_exporter": "python", 161 | "pygments_lexer": "ipython3", 162 | "version": "3.10.10" 163 | }, 164 | "orig_nbformat": 4 165 | }, 166 | "nbformat": 4, 167 | "nbformat_minor": 2 168 | } 169 | --------------------------------------------------------------------------------