55:: Last updated: 2020-08-23
66:: >>> Get updated from: https://github.com/LmeSzinc/AzurLaneAutoScript <<<
77@ echo off
8+ chcp | find " 932" > NUL && set " IME = true" || set " IME = false"
9+ if " %IME% " == " true" (
10+ echo ====================================================================================================
11+ echo Incorrect encoding, visit this link to correct: https://bit.ly/34t8ubY
12+ echo To copy, select the link and CTRL+SHFT+C
13+ echo ====================================================================================================
14+ pause
15+ goto :eof
16+ )
817pushd " %~dp0 "
918setlocal EnableDelayedExpansion
1019set " Version = 3.0"
@@ -19,6 +28,17 @@ set "root=%~dp0"
1928set " root = %root:~0 ,-1 % "
2029cd " %root% "
2130
31+ rem ================= Variables =================
32+
33+ set " pyBin = %root% \toolkit\python.exe"
34+ set " adbBin = %root% \toolkit\Lib\site-packages\adbutils\binaries\adb.exe"
35+ set " gitBin = %root% \toolkit\Git\mingw64\bin\git.exe"
36+ set " curlBin = %root% \toolkit\Git\mingw64\bin\curl.exe"
37+ set " api_json = %root% \config\api_git.json"
38+ set " AlasConfig = %root% \config\alas.ini"
39+ set " template = %root% \config\template.ini"
40+ set " gitFolder = %root% \.git"
41+
2242:: Import main settings (%Language%, %Region%, %SystemType%) and translation text.
2343call command\Get.bat Main
2444:: Import the Proxy setting and apply. Then show more info in Option6.
@@ -32,14 +52,6 @@ call command\Get.bat DeployMode
3252
3353:: Start of Deployment
3454title Alas Run Tool V3
35- set " pyBin = %root% \toolkit\python.exe"
36- set " adbBin = %root% \toolkit\Lib\site-packages\adbutils\binaries\adb.exe"
37- set " gitBin = %root% \toolkit\Git\mingw64\bin\git.exe"
38- set " curlBin = %root% \toolkit\Git\mingw64\bin\curl.exe"
39- set " api_json = %root% \config\api_git.json"
40- set " AlasConfig = %root% \config\alas.ini"
41- set " template = %root% \config\template.ini"
42- set " gitFolder = %root% \.git"
4355if " %IsUsingGit% " == " yes" if " %DeployMode% " == " unknown" ( xcopy /Y toolkit\config .git\ > NUL )
4456call :UpdateChecker_Alas
4557
@@ -104,7 +116,6 @@ rem ================= OPTION 1 =================
104116:en
105117call :CheckBsBeta
106118call :AdbConnect
107- rem call :uiautomator2init
108119echo ====================================================================================================
109120echo Python Found in %pyBin% Proceeding..
110121echo Opening alas_en.pyw in %root%
@@ -118,7 +129,6 @@ rem ================= OPTION 2 =================
118129:cn
119130call :CheckBsBeta
120131call :AdbConnect
121- rem call :uiautomator2init
122132echo ====================================================================================================
123133echo Python Found in %pyBin% Proceeding..
124134echo Opening alas_en.pyw in %root%
@@ -131,7 +141,6 @@ rem ================= OPTION 3 =================
131141:jp
132142call :CheckBsBeta
133143call :AdbConnect
134- rem call :uiautomator2init
135144echo ====================================================================================================
136145echo Python Found in %pyBin% Proceeding..
137146echo Opening alas_en.pyw in %root%
@@ -413,6 +422,11 @@ goto ReturnToSetting
413422
414423rem ================= FUNCTIONS =================
415424
425+ :CheckAdbConnect
426+ for /f " tokens=1*" %%g IN ('%adbBin% connect 127.0.0.1:5555') do set adbCheck = %%g
427+ if " %adbCheck% " == " cannot"
428+ echo %adbCheck%
429+
416430:ReturnToSetting
417431echo . & echo Press any key to continue...
418432pause > NUL
@@ -444,6 +458,7 @@ for /f "tokens=3" %%a in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks_bgp6
444458set SerialRealtime = 127.0.0.1:%port%
445459echo ====================================================================================================
446460echo connecting at %SerialRealtime%
461+ %adbBin% kill-server > nul 2 >& 1
447462%adbBin% connect %SerialRealtime%
448463echo ====================================================================================================
449464if " %FirstRun% " == " yes" (
@@ -456,14 +471,23 @@ echo Old Serial: %SerialAlas%
456471echo New Serial: %SerialRealtime%
457472echo ====================================================================================================
458473echo Press any to continue...
474+ %pyBin% -m uiautomator2 init
459475pause > NUL
460476:: -----------------------------------------------------------------------------
461477goto :eof
462478
463479:AdbConnect
464480if " %RealtimeMode% " == " enable" goto :eof
465- if " %FirstRun% " == " yes" ( %adbBin% connect %serial_input% && goto :eof )
466- %adbBin% connect %Serial%
481+ if " %FirstRun% " == " yes" ( goto :eof )
482+ %adbBin% kill-server > nul 2 >& 1
483+ %adbBin% connect %Serial% | find /i " connected to" > nul
484+ if errorlevel 1 (
485+ echo The connection was not successful
486+ goto Serial_setting
487+ ) else (
488+ %pyBin% -m uiautomator2 init
489+ echo The connection was Successful
490+ )
467491goto :eof
468492
469493:KillAdb
0 commit comments