forked from LmeSzinc/AzurLaneAutoScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev_tools.bat
273 lines (263 loc) · 8.14 KB
/
dev_tools.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
@echo off
setlocal EnableDelayedExpansion
title Dev_tools
pushd "%~dp0"
:: -----------------------------------------------------------------------------
SET ADB_PATH=%~dp0toolkit\Lib\site-packages\adbutils\binaries\adb.exe
SET ADB=%ADB_PATH%
SET PYTHON_PATH=%~dp0toolkit\python.exe
SET PYTHON=%PYTHON_PATH%
:: -----------------------------------------------------------------------------
goto check_Permissions
:check_Permissions
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
pause >nul
goto continue
) else (
echo Failure: Current permissions inadequate.
)
pause >nul
:: -----------------------------------------------------------------------------
:continue
set FILE_PREFIX=screenshot
set SCREENSHOT_FOLDER=%~dp0screenshots
if not exist %SCREENSHOT_FOLDER% (
mkdir %SCREENSHOT_FOLDER%
)
:: -----------------------------------------------------------------------------
if not exist adb_port.ini (
cd . > adb_port.ini
)
set "adb_empty=*adb_port.ini"
for %%A in (%adb_empty%) do if %%~zA==0 (
echo enter your HOST:PORT eg: 127.0.0.1:5555 for default bluestacks
set /p adb_input=
)
REM if adb_input = 0 load from adb_port.ini
if [%adb_input%]==[] (
goto load
)
REM write adb_input on adb_port.ini
echo %adb_input% >> adb_port.ini
REM Load adb_port.ini
:load
REM
set /p ADB_PORT=<adb_port.ini
echo connecting at %ADB_PORT%
CALL %ADB% connect %ADB_PORT%
:: -----------------------------------------------------------------------------
:dev_menu
cls
echo.
echo :: Dev_tools
echo.
echo 1. emulator_test
echo 2. button_extract
echo 3. grids_debug
echo 4. item_stastistics
echo 5. relative_crop
echo 6. map_extractor
echo 7. word_template_extractor
echo 8. ADB SCREENSHOT (for ASSETS)
echo 9. Uiautomator2 SCREENSHOT (for ASSETS)
echo 10. ADB SCREENSHOT (Continuous Screenshot)
echo.
echo :: Type a 'number' and press ENTER
echo :: Type 'exit' to quit
echo.
set /P menu=
if %menu%==1 GOTO emulator_test
if %menu%==2 GOTO button_extract
if %menu%==3 GOTO grids_debug
if %menu%==4 GOTO item_stastistics
if %menu%==5 GOTO relative_crop
if %menu%==6 GOTO map_extractor
if %menu%==7 GOTO word_template_extractor
if %menu%==8 GOTO adbss
if %menu%==9 GOTO u2ss
if %menu%==10 GOTO adbc
if %menu%==exit GOTO EOF
else (
cls
echo.
echo :: Incorrect Input Entered
echo.
echo Please type a 'number' or 'exit'
echo Press any key to retry to the menu...
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:emulator_test
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.emulator_test...
call %PYTHON% -m dev_tools.emulator_test
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.emulator_test, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:button_extract
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.button_extract
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.button_extract, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:grids_debug
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.grids_debug
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.grids_debug, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:item_stastistics
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.item_stastistics
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.item_stastistics, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:relative_crop
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.relative_crop
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.relative_crop, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:map_extractor
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.map_extractor
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.map_extractor, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:word_template_extractor
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.word_template_extractor
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.word_template_extractor, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:adbss
echo Enter any text/letter instead of the file name, do not enter spaces, enter exit to exit
echo or enter alas to back to main menu
echo.
:set
SET time=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
SET name=%time%
SET /P name=
IF /I '%name%'=='exit' goto EOF
IF /I '%name%'=='alas' goto dev_menu
call %ADB% -s %ADB_PORT% shell mkdir /sdcard/dcim/Screenshot 2>nul
call %ADB% -s %ADB_PORT% shell screencap -p /sdcard/dcim/Screenshot/%name%.png
call %ADB% -s %ADB_PORT% pull /sdcard/dcim/Screenshot/%name%.png %SCREENSHOT_FOLDER%\%name%.png
call %ADB% -s %ADB_PORT% shell rm /sdcard/dcim/Screenshot/%name%.png
echo.
echo The file %name%.png has been copied to ./screenshots/ directory
echo.
SET time=
if NOT ["%errorlevel%"]==["0"] (
pause
exit /b %errorlevel%
)
goto adbss
:: -----------------------------------------------------------------------------
:u2ss
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening dev_tools.button_extract...
call %PYTHON% -m dev_tools.uiautomator2_screenshot
echo The file *.png has been copied to ./screenshots/ directory
pause > NUL
goto dev_menu
) else (
echo :: it was not possible to open dev_tools.uiautomator2_screenshot, make sure you have a folder toolkit
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto dev_menu
)
:: -----------------------------------------------------------------------------
:adbc
rem create output file name and path from parameters and date and time
rem loop
:CLOCK
rem FOR /L %%A IN (1,1,1) DO (
rem removing the upper for loop
set Timestamp=%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-%time:~9,2%
set SCREENCAP_FILE_NAME=%FILE_PREFIX%-%Timestamp%.png
set SCREENCAP_FILE_PATH=%SCREENSHOT_FOLDER%%SCREENCAP_FILE_NAME%
rem calling adb shell screencap, pull and remove the previos file
call %ADB% shell screencap -p %SCREENCAP_FILE_PATH%
call %ADB% pull %SCREENCAP_FILE_PATH%
call %ADB% shell rm %SCREENCAP_FILE_PATH%
goto:CLOCK
:EOF
exit