1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-22 07:03:43 +08:00

Fix: fixed bluestacks hyper-v multi-instance support

This commit is contained in:
whoamikyo
2021-02-13 00:53:19 -03:00
parent df15fc4b57
commit e72605ba95
6 changed files with 58 additions and 36 deletions

View File

@@ -62,6 +62,7 @@ call command\Get.bat DeployMode
:: Start of Deployment :: Start of Deployment
set "pipLog=%root%\toolkit\log\pip_update_log_%datetime%.log" set "pipLog=%root%\toolkit\log\pip_update_log_%datetime%.log"
set "pipLogFolder=%root%\toolkit\log\"
if "%IsUsingGit%"=="yes" if "%DeployMode%"=="unknown" ( xcopy /Y toolkit\config .git\ > NUL ) if "%IsUsingGit%"=="yes" if "%DeployMode%"=="unknown" ( xcopy /Y toolkit\config .git\ > NUL )
call :UpdateChecker_Alas call :UpdateChecker_Alas
title ^| Alas Run Tool V3 ^| Branch: %BRANCH% ^| Git hash: %LAST_LOCAL_GIT% ^| commit date: %GIT_CTIME% ^| title ^| Alas Run Tool V3 ^| Branch: %BRANCH% ^| Git hash: %LAST_LOCAL_GIT% ^| commit date: %GIT_CTIME% ^|
@@ -219,12 +220,9 @@ if "%KeepLocalChanges%"=="disable" (
%gitBin% reset --hard %source%/%Branch% %gitBin% reset --hard %source%/%Branch%
%gitBin% pull --ff-only %source% %Branch% %gitBin% pull --ff-only %source% %Branch%
echo == ^| DONE! echo == ^| DONE!
if "%AutoMode%"=="enable" ( echo. & echo == ^| Please re-run this batch to make the settings take effect.
echo. & echo == ^| Press any key to proceed to %DefaultServer% echo == ^| Please re-run the "alas.bat" to make the settings take effect.
goto %DefaultServer% ) goto PleaseRerun
echo == ^| Press any key to proceed
pause > NUL
goto MENU
) else ( ) else (
echo == ^| GIT Found in %gitBin% Proceeding echo == ^| GIT Found in %gitBin% Proceeding
echo == ^| Updating from %source% repository.. echo == ^| Updating from %source% repository..
@@ -232,16 +230,11 @@ if "%KeepLocalChanges%"=="disable" (
%gitBin% pull %source% %Branch% %gitBin% pull %source% %Branch%
%gitBin% stash pop %gitBin% stash pop
echo == ^| DONE! echo == ^| DONE!
if "%AutoMode%"=="enable" ( echo == ^| DONE!
echo. & echo == ^| Press any key to proceed to %DefaultServer% Server echo. & echo == ^| Please re-run this batch to make the settings take effect.
goto %DefaultServer% ) echo == ^| Please re-run the "alas.bat" to make the settings take effect.
echo == ^| Press any key to proceed goto PleaseRerun
pause > NUL
goto MENU
) )
echo. & echo == ^| Please re-run this batch to make the settings take effect.
echo == ^| Please re-run the "alas.bat" to make the settings take effect.
goto PleaseRerun
:update_toolkit :update_toolkit
@@ -882,23 +875,36 @@ goto :eof
:CheckBsBeta :CheckBsBeta
call :process_checker call :process_checker
if "%RealtimeMode%"=="disable" ( goto AdbConnect ) if "%RealtimeMode%"=="disable" ( goto AdbConnect )
for /f skip^=1^ tokens^=17^ delims^=^" %%a in ('tasklist /fi "imagename eq bluestacks.exe" /fo:csv /v /fi "status ne NOT RESPONDING"') do ( set WINDOW=%%a ) if Not "%DefaultBluestacksInstance%"=="unknown" ( goto CheckBsBeta2)
rem set WINDOW=%WINDOW:"=% echo =======================================================================================================================
set WINDOW=%WINDOW: =% echo == ^| Please input which instance of your Bluestacks Hyper-V Beta you will use
if not "%WINDOW%"=="BlueStacks" ( echo == ^| if you have only one Bluestacks Hyper-V Beta instance type 0 or press Enter
set WINDOW=%WINDOW:~10,1% echo == ^| the first instance will always be 0, and the subsequent ones will follow the numerical order
echo == BlueStacks instance %WINDOW% detected echo =======================================================================================================================
) else ( set DefaultBluestacksInstance=0
echo == Bluestacks instance 1 detected set /p DefaultBluestacksInstance= Please input the instance of your Bluestacks Hyper-V Beta
) call command\Config.bat DefaultBluestacksInstance %DefaultBluestacksInstance%
if "%WINDOW%"=="BlueStacks" ( rem if /i "%DefaultBluestacksInstance%"=="C" ( goto Emulator_Setup )
set folderName=Android echo =======================================================================================================================
) else ( rem for /f skip^=1^ tokens^=17^ delims^=^" %%a in ('tasklist /fi "imagename eq bluestacks.exe" /fo:csv /v /fi "status ne NOT RESPONDING"') do ( set WINDOW=%%a )
set folderName=Android_%WINDOW% rem rem set WINDOW=%WINDOW:"=%
) rem set WINDOW=%WINDOW: =%
rem if not "%WINDOW%"=="BlueStacks" (
rem set WINDOW=%WINDOW:~10,1%
rem echo == BlueStacks instance %WINDOW% detected
rem ) else (
rem echo == Bluestacks instance 1 detected
rem )
rem if "%WINDOW%"=="BlueStacks" (
rem set folderName=Android
rem ) else (
rem set folderName=Android_%WINDOW%
rem )
:CheckBsBeta2
if "%DefaultBluestacksInstance%"=="0" ( set folderName=Android ) else ( set folderName=Android_%DefaultBluestacksInstance% )
set HYPERVREG=HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks_bgp64_hyperv\Guests\%folderName%\Config set HYPERVREG=HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks_bgp64_hyperv\Guests\%folderName%\Config
set HYPERVREG=%HYPERVREG: =% set HYPERVREG=%HYPERVREG: =%
echo == Connecting with realtime mode... echo == ^| Connecting with realtime mode...
for /f "tokens=3" %%a in ('reg query %HYPERVREG% /v BstAdbPort') do (set /a port = %%a) for /f "tokens=3" %%a in ('reg query %HYPERVREG% /v BstAdbPort') do (set /a port = %%a)
set SerialRealtime=127.0.0.1:%port% set SerialRealtime=127.0.0.1:%port%
@@ -906,7 +912,7 @@ echo ===========================================================================
if "%KillServer%"=="enable" ( if "%KillServer%"=="enable" (
%adbBin% kill-server > nul 2>&1 %adbBin% kill-server > nul 2>&1
) )
echo == connecting at %SerialRealtime% echo == ^| connecting at %SerialRealtime% in Bluestacks instance: %DefaultBluestacksInstance%
%adbBin% connect %SerialRealtime% > nul %adbBin% connect %SerialRealtime% > nul
if "%FirstRun%"=="yes" ( if "%FirstRun%"=="yes" (
call command\Config.bat Serial %SerialRealtime% call command\Config.bat Serial %SerialRealtime%
@@ -918,12 +924,12 @@ if "%FirstRun%"=="yes" (
call command\Config.bat Serial %SerialRealtime% call command\Config.bat Serial %SerialRealtime%
) )
echo ======================================================================================================================= echo =======================================================================================================================
echo == Old Serial: %SerialAlas% echo == ^| Old Serial: %SerialAlas%
echo == New Serial: %SerialRealtime% echo == ^| New Serial: %SerialRealtime%
echo ======================================================================================================================= echo =======================================================================================================================
%pyBin% -m uiautomator2 init %pyBin% -m uiautomator2 init
echo ======================================================================================================================= echo =======================================================================================================================
echo == The connection was Successful on SERIAL: %SerialRealtime% echo == ^| The connection was Successful on SERIAL: %SerialRealtime%
goto :eof goto :eof
rem ================= FUNCTIONS ================= rem ================= FUNCTIONS =================
@@ -1027,7 +1033,7 @@ if %LAST_LOCAL_GIT% == %sha% (
echo == ^| Current Local Branch: ^| %BRANCH% echo == ^| Current Local Branch: ^| %BRANCH%
echo ======================================================================================================================= echo =======================================================================================================================
echo. && echo == ^| Deleting older .PNG under Log folder, it may take while, it depends on the amount of files you have... echo. && echo == ^| Deleting older .PNG under Log folder, it may take while, it depends on the amount of files you have...
forfiles /P %logFolder% /S /M *.png /D -3 /C "cmd /c del @PATH" 2>nul forfiles /P %logFolder% /S /M *.png /D -3 /C "cmd /c del @PATH" 2>nul && forfiles /P %pipLogFolder% /S /M *.log /D -7 /C "cmd /c del @PATH" 2>nul
echo == Your ALAS is updated, Press any to continue or wait... echo == Your ALAS is updated, Press any to continue or wait...
timeout /t 5 >nul timeout /t 5 >nul
goto :eof goto :eof

View File

@@ -31,6 +31,7 @@ if NOT exist %cfg_Deploy% (
echo NetTest = disable echo NetTest = disable
echo KeepLocalChanges = disable echo KeepLocalChanges = disable
echo RealtimeMode = disable echo RealtimeMode = disable
echo DefaultBluestacksInstance = unknown
echo AdbConnect = enable echo AdbConnect = enable
echo AdbKillServer = enable echo AdbKillServer = enable
echo Serial = %SerialDeploy% echo Serial = %SerialDeploy%
@@ -156,6 +157,15 @@ for /f "delims=" %%i in (%cfg_Deploy%.bak) do (
) )
goto :eof goto :eof
:Config_DefaultBluestacksInstance
for /f "delims=" %%i in (%cfg_Deploy%.bak) do (
set "cfg_Content=%%i"
echo %%i | findstr "DefaultBluestacksInstance" >NUL && ( set "cfg_Content=DefaultBluestacksInstance = %DefaultBluestacksInstance%" )
echo !cfg_Content!>>%cfg_Deploy%
)
goto :eof
:Config_KeepLocalChanges :Config_KeepLocalChanges
for /f "delims=" %%i in (%cfg_Deploy%.bak) do ( for /f "delims=" %%i in (%cfg_Deploy%.bak) do (
set "cfg_Temp=%%i" set "cfg_Temp=%%i"

View File

@@ -52,6 +52,9 @@ if exist config\deploy.ini ( goto CheckFields )
for /f "tokens=3 delims= " %%i in ('findstr /i "IsUsingGit" config\deploy.ini') do ( set "IsUsingGit=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "IsUsingGit" config\deploy.ini') do ( set "IsUsingGit=%%i" )
for /f "tokens=3 delims= " %%i in ('findstr /i "KeepLocalChanges" config\deploy.ini') do ( set "KeepLocalChanges=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "KeepLocalChanges" config\deploy.ini') do ( set "KeepLocalChanges=%%i" )
for /f "tokens=3 delims= " %%i in ('findstr /i "RealtimeMode" config\deploy.ini') do ( set "RealtimeMode=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "RealtimeMode" config\deploy.ini') do ( set "RealtimeMode=%%i" )
findstr /i "DefaultBluestacksInstance" config\deploy.ini>nul
if "%errorlevel%" == "1" ( ( echo DefaultBluestacksInstance = unknown)>>config\deploy.ini )
for /f "tokens=3 delims= " %%i in ('findstr /i "DefaultBluestacksInstance" config\deploy.ini') do ( set "DefaultBluestacksInstance=%%i" )
for /f "tokens=3 delims= " %%i in ('findstr /i "Branch" config\deploy.ini') do ( set "Branch=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "Branch" config\deploy.ini') do ( set "Branch=%%i" )
for /f "tokens=3 delims= " %%i in ('findstr /i "AdbConnect" config\deploy.ini') do ( set "AdbConnect=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "AdbConnect" config\deploy.ini') do ( set "AdbConnect=%%i" )
for /f "tokens=3 delims= " %%i in ('findstr /i "Serial" config\deploy.ini') do ( set "SerialDeploy=%%i" ) for /f "tokens=3 delims= " %%i in ('findstr /i "Serial" config\deploy.ini') do ( set "SerialDeploy=%%i" )

View File

@@ -141,7 +141,7 @@ class CampaignBase(CampaignUI, Map, AutoSearchCombat):
self.auto_search_execute_a_battle() self.auto_search_execute_a_battle()
except CampaignEnd: except CampaignEnd:
logger.hr('Campaign end') logger.hr('Campaign end')
self.device.send_notification('AzurLaneAutoScript', 'Campaign end') self.device.send_notification('AzurLaneAutoScript', 'Map cleared')
return True return True
# Exception # Exception

View File

@@ -86,6 +86,7 @@ class LoginHandler(Combat):
continue continue
logger.warning('Login failed more than 3') logger.warning('Login failed more than 3')
self.device.send_notification('AzurLaneAutoScript', 'Login failed more than 3')
raise ScriptError('Login failed more than 3') raise ScriptError('Login failed more than 3')
def app_restart(self): def app_restart(self):
@@ -127,6 +128,7 @@ class LoginHandler(Combat):
def handle_game_stuck(self): def handle_game_stuck(self):
logger.warning(f'{self.config.PACKAGE_NAME} will be restart in 10 seconds') logger.warning(f'{self.config.PACKAGE_NAME} will be restart in 10 seconds')
logger.warning('If you are playing by hand, please stop Alas') logger.warning('If you are playing by hand, please stop Alas')
self.device.send_notification('AzurLaneAutoScript', 'Game stucked, will be restart in 10 seconds')
self.device.sleep(10) self.device.sleep(10)
self.app_restart() self.app_restart()

View File

@@ -269,6 +269,7 @@ class Fleet(Camera, AmbushHandler):
continue continue
if self.handle_walk_out_of_step(): if self.handle_walk_out_of_step():
self.device.send_notification('AzurLaneAutoScript', 'Walk out of step error, please check GUI.')
raise MapWalkError('walk_out_of_step') raise MapWalkError('walk_out_of_step')
# Arrive # Arrive