Skip to content

Commit

Permalink
添加使用 exe 文件的说明
Browse files Browse the repository at this point in the history
  • Loading branch information
ccc007ccc committed Jul 22, 2024
1 parent 822467d commit 58aac6c
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 114 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
./vscode
/.vscode
/output
/temp_build
/build
21 changes: 0 additions & 21 deletions .vscode/c_cpp_properties.json

This file was deleted.

66 changes: 0 additions & 66 deletions .vscode/settings.json

This file was deleted.

45 changes: 45 additions & 0 deletions Build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@echo off
REM 设置字符编码为 UTF-8
chcp 65001
cls

REM compile_WebServer.bat

REM 设置变量
set "SCRIPT_NAME=start.py"
set "EXE_NAME=zzz-snake.exe"
set "TEMP_DIR=temp_build"
set "OUTPUT_DIR=output"

REM 创建临时目录和输出目录
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"

REM 安装必要的 Python 包
echo 正在安装必要的 Python 包...
pip install pyinstaller
pip install -r requirements.txt

REM 复制 Python 脚本到临时目录
copy "%SCRIPT_NAME%" "%TEMP_DIR%"

REM 切换到临时目录
cd "%TEMP_DIR%"

REM 使用 PyInstaller 编译脚本
echo 正在编译脚本...
pyinstaller -D --uac-admin --onefile --name "%EXE_NAME%" "%SCRIPT_NAME%"

REM 将生成的 EXE 文件移动到输出目录
move "dist\%EXE_NAME%" "..\%OUTPUT_DIR%"

REM 切换回原始目录
cd ..

REM 清理临时文件
rmdir /s /q "%TEMP_DIR%"

echo 编译完成!executable 文件位于: %OUTPUT_DIR%\%EXE_NAME%

REM 暂停以查看输出
pause
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
# 绝区零蛇对蛇全自动刷分脚本

此Python脚本通过模拟键盘输入来自动控制蛇进行刷分。脚本会让蛇以原地转圈的方式移动并在失败后自动重新开始,从而实现全自动刷分(很难刷到千万分以上).

## 安装方法

1. 安装库`pip install keyboard pyautogui`
2. 克隆存储库`git clone https://github.com/1492949083/ZenlessZoneZero-Snake.git`
4. 运行`python start.py`
5. 在蛇对蛇游戏中,按下 `F10` 键开始自动刷分(不用操控,脚本会自动将蛇移动到角落)。
6. 按下 `F11` 键暂停刷分。
7. Ctrl + C 退出
通过模拟键盘输入来自动控制蛇进行刷分。让蛇以原地转圈的方式移动并在失败后自动重新开始,从而实现全自动刷分(很难刷到千万分以上)。

## 使用方法

### 使用打包好的 exe 文件

1. 下载打包好的 exe 文件。
2. 从蛇对蛇失败界面[此处](doc/img/1.png)截图取名 `image.png` 和 exe 文件放一起![s](doc/img/2.png)
3. 双击运行 exe 文件。
4. 在蛇对蛇游戏中,按下 `F10` 键开始自动刷分(脚本会自动将蛇移动到角落)。
5. 按下 `F11` 键暂停刷分。
6. 关闭窗口退出。

### 使用源代码

1. 安装所需库:
```sh
pip install -r requirements.txt
```
2. 克隆存储库:
```sh
git clone https://github.com/1492949083/ZenlessZoneZero-Snake.git
cd ZenlessZoneZero-Snake
```
3. 运行脚本:
```sh
python start.py
```
4. 在蛇对蛇游戏中,按下 `F10` 键开始自动刷分(脚本会自动将蛇移动到角落)。
5. 按下 `F11` 键暂停刷分。
6. 按 `Ctrl + C` 退出。

## 注意事项

Expand All @@ -18,7 +39,8 @@

## 常见问题

- 如果游戏失败后不会自动重新开始,请将游戏结束界面此处截图并替换/img/image.png文件。![image](doc/img/1.png)
- 如果游戏失败后不会自动重新开始,请将游戏结束界面截图并替换 `image.png` 文件。
![image](doc/img/1.png)

## 免责声明

Expand Down
Binary file added doc/img/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
keyboard
pyautogui
opencv-python
39 changes: 24 additions & 15 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import threading
import pyautogui as pyg
import os

# 用于表示脚本是否应该继续运行
continue_running = False
Expand All @@ -12,7 +13,6 @@
timer_lock = threading.Lock()
rounds = 0


# 去左上角
def go_to_top_left():
global continue_running
Expand Down Expand Up @@ -89,29 +89,34 @@ def timer():
def click_over_img():
global rounds,continue_running
height, width = pyg.size()
print(height, width)
# print(height, width)
#左上角
left_top_x = int(width/3)
left_top_y = int(height/3)
#右下角
right_bottom_x = int(width - width/3)
right_bottom_y = int(height - height/3)
print(left_top_x, left_top_y, right_bottom_x, right_bottom_y)
# print(left_top_x, left_top_y, right_bottom_x, right_bottom_y)

while pag_running:
img = pyg.locateCenterOnScreen("./img/image.png", confidence=0.8, region=(left_top_x, left_top_y, right_bottom_x, right_bottom_y))
if img != None:
continue_running = False
pyg.click(img)
time.sleep(1.5)
go_to_top_left()
rounds += 1
elif rounds == 0:
# continue_running = True
go_to_top_left()
rounds = 1
try:
img = pyg.locateCenterOnScreen("image.png", confidence=0.8, region=(left_top_x, left_top_y, right_bottom_x, right_bottom_y))
if img != None:
continue_running = False
pyg.click(img)
time.sleep(1.5)
go_to_top_left()
rounds += 1
elif rounds == 0:
# continue_running = True
go_to_top_left()
rounds = 1
except pyg.ImageNotFoundException:
# print("图片未找到")
continue
finally:
time.sleep(1)

time.sleep(1)

# 当 F10 键被按下时,调用 start_script 函数
keyboard.on_press_key("f10", start_script)
Expand All @@ -130,5 +135,9 @@ def click_loop():
# 在一个新的线程中运行 click_loop 函数
threading.Thread(target=click_loop, daemon=True).start()

print("F10 键启动")
print("F11 键暂停")
print("Ctrl+C 键退出")

# 运行程序
keyboard.wait()

0 comments on commit 58aac6c

Please sign in to comment.