Merge pull request #55 from whoamikyo/master

Tweaks: Added improvements on Easy_Install
This commit is contained in:
LmeSzinc 2020-06-24 20:36:11 +08:00 committed by GitHub
commit 8fd4f8ccd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 216 additions and 82 deletions

View File

@ -1,14 +1,25 @@
@SETLOCAL EnableExtensions EnableDelayedExpansion
@echo off
pushd "%~dp0"
:: VARIABLES INSTALL
SET CMD=%SystemRoot%\system32\cmd.exe
SET LMESZINC=https://github.com/LmeSzinc/AzurLaneAutoScript.git
SET WHOAMIKYO=https://github.com/whoamikyo/AzurLaneAutoScript.git
rem SET ROOT_UPPER=%~dp0
rem SET ADB_PATH=%AZURLANESCRIPT%\python-3.7.6.amd64\Lib\site-packages\adbutils\binaries
:: -----------------------------------------------------------------------------
:: Make sure we're running with administrator privileges
echo.
echo :: Checking For Administrator Elevation...
echo.
timeout /t 1 /nobreak > NUL
openfiles > NUL 2>&1
if %errorlevel%==0 (
net session >nul 2>&1
if %errorLevel% == 0 (
echo Elevation found! Proceeding...
) else (
goto menu
) else (
echo :: You are NOT running as Administrator
echo.
echo Right-click and select ^'Run as Administrator^' and try again.
@ -16,11 +27,36 @@ if %errorlevel%==0 (
pause > NUL
exit
)
REM PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
:: -----------------------------------------------------------------------------
set PATH=%PATH%;%PROGRAMDATA%\chocolatey\lib\adb\tools\platform-tools\;%PROGRAMFILES%\Git\cmd;%PROGRAMDATA%\chocolatey\bin
:: Make sure the second path exists. The first path won't be created until the second script is run
rem IF NOT EXIST !ADB_PATH! (ECHO Path not found: %ADB_PATH% && GOTO ExitBatch)
:: -----------------------------------------------------------------------------
:: Add paths
rem CALL :AddPath %ADB_PATH%
rem CALL :AddPath %GIT_PATH%
rem CALL :AddPath %AZURLANESCRIPT%
rem CALL :AddPath %ROOT_UPPER%
pause
:: Branch to UpdateEnv if we need to update
REM IF DEFINED UPDATE (GOTO UpdateEnv)
REM GOTO ExitBatch
:: -----------------------------------------------------------------------------
REM :UpdateEnv
REM ECHO Making updated PATH go live . . .
REM REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1
REM setx TEMPVAR 1 > nul 2>&1
REM REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1
REM IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer)
REM GOTO ExitBatch
:: -----------------------------------------------------------------------------
goto menu
:menu
cls
echo.
@ -28,25 +64,24 @@ goto menu
echo.
echo This script will install Python 3.7.6 + requirements.txt + ADB + GIT + CHOCOLATEY
echo.
echo :: For fresh install, Run from step "1" to "3"
echo :: For fresh install, Run step "1" and "2"
echo.
echo 1.Essentials programs
echo 1.Python 3.7.6 + ADB + GIT + requirements.txt
echo 2.Clone repository (Download the latest version from LmeSzinc repository)
echo 3.Python 3.7.6 + requirements.txt
echo 3.Programs (ADB + GIT Alternative way with CHOCOLATEY)
echo 4.Updater ONLY (Do not update if you are doing a fresh install)
echo.
echo JUST RUN UPDATER INSIDE AzurLaneAutoScript FOLDER
echo JUST RUN UPDATER INSIDE AzurLaneAutoScript FOLDER
echo.
echo Install in order
echo Install in order
echo.
echo :: Type a 'number' and press ENTER
echo :: Type 'exit' to quit
echo.
set /P menu=
if %menu%==1 GOTO programs
if %menu%==1 GOTO python
if %menu%==2 GOTO clone
if %menu%==3 GOTO python
if %menu%==3 GOTO programs
if %menu%==4 GOTO updater
if %menu%==exit GOTO EOF
@ -61,8 +96,7 @@ goto menu
pause > NUL
goto menu
)
:: -----------------------------------------------------------------------------
:programs
cls
echo.
@ -92,85 +126,122 @@ cls
echo :: if you have problems I suggest uninstalling all packages mentioned in the control panel (windows)
echo.
timeout /t 1 /nobreak > NUL
SET PATH=%PATH%;%PROGRAMDATA%\chocolatey\lib\adb\tools\platform-tools\;%PROGRAMFILES%\Git\cmd;%PROGRAMDATA%\chocolatey\bin
echo Installing chocolatey on this machine
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))">>chocolatey-%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
)
echo Installing Essentials programs, It may take
@powershell -NoProfile -ExecutionPolicy Bypass -Command "choco install -y --force --allow-empty-checksums adb git">>Essentials-%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log
)
:: timout
PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
call refreshenv
set PATH=%PATH%;%PROGRAMDATA%\chocolatey\lib\adb\tools\platform-tools\
goto menu
:: -----------------------------------------------------------------------------
:: killing adb server
call adb --version >nul
:killadb
call %ADB_PATH% --version >nul
if %errorlevel% == 0 (
echo ADB Found! Proceeding..
echo killing adb server..
call adb kill-server > nul 2>&1
call %ADB_PATH% kill-server > nul 2>&1
goto menu
) else (
echo :: ADB not found, maybe there was an installation issue, try opening another CMD window and type choco install adb
echo.
pause > NUL
)
REM call adb kill-server > nul 2>&1
goto menu
goto menu
)
:: -----------------------------------------------------------------------------
:clone
set ROOT=%~dp0AzurLaneAutoScript
SET PATH=%PATH%;%PROGRAMFILES%\Git\cmd
echo Cloning repository
if exist %ROOT% (
RMDIR /S /Q %ROOT%
)
call git --version >nul
SET AZURLANESCRIPT=%~dp0AzurLaneAutoScript
SET GIT_PATH=%AZURLANESCRIPT%\python-3.7.6.amd64\Git\cmd
SET GIT=%GIT_PATH%\git.exe
call %GIT% --version >nul
if %errorlevel% == 0 (
echo Cloning repository
echo GIT Found! Proceeding..
echo Cloning repository...
call git clone https://github.com/LmeSzinc/AzurLaneAutoScript.git && cd AzurLaneAutoScript && git remote add whoamikyo https://github.com/whoamikyo/AzurLaneAutoScript.git
cd %AZURLANESCRIPT%
echo Deleting folder unused files
for /D %%D in ("*") do (
if /I not "%%~nxD"=="python-3.7.6.amd64" rd /S /Q "%%~D"
)
for %%F in ("*") do (
del "%%~F"
)
echo ## initializing..
call %GIT% init
echo ## adding origin..
call %GIT% remote add origin %LMESZINC%
echo ## pulling project...
call %GIT% pull origin master
echo ## setting default branch...
call %GIT% branch --set-upstream-to=origin/master master
call %GIT% remote add whoamikyo %WHOAMIKYO%
echo The installation was successful
echo Press any key to proceed
pause > NUL
goto menu
) else (
echo :: Git not found, maybe there was an installation issue, try opening another CMD window and type choco install git
echo.
pause > NUL
)
REM PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
goto menu
)
:: -----------------------------------------------------------------------------
:python
cls
echo.
echo :: Installing Python 3.7.6 + requirements.txt
echo :: Python 3.7.6 + ADB + GIT + requirements.txt
echo.
echo.
set ROOT=%~dp0AzurLaneAutoScript
set FILE_URL="https://gitlab.com/whoamikyo/alas-venv/-/raw/master/python.zip"
set FILE_DEST=%ROOT%\pythonpackage.zip
if not exist %ROOT% (
mkdir %ROOT%
SET PYTHON=%~dp0AzurLaneAutoScript/python-3.7.6.amd64/python.exe
SET AZURLANESCRIPT=%~dp0AzurLaneAutoScript
SET FILE_URL=https://gitlab.com/whoamikyo/alas-venv/-/raw/master/python.zip
SET FILE_DEST=%AZURLANESCRIPT%\pythonpackage.zip
if not exist %AZURLANESCRIPT% (
echo WILL BE CREATED A FOLDER "AzurLaneAutoScript"
echo DO NOT RENAME THE FOLDER NEVER
mkdir %AZURLANESCRIPT%
)
if not exist "%FILE_DEST%" (
echo Downloading with powershell: %FILE_URL% to %FILE_DEST%
powershell.exe -command "$webclient = New-Object System.Net.WebClient; $url = \"%FILE_URL%\"; $file = \"%FILE_DEST%\"; $webclient.DownloadFile($url,$file);"
echo Expanding with powershell to: %ROOT%
powershell -command "$shell_app=new-object -com shell.application; $zip_file = $shell_app.namespace(\"%FILE_DEST%\"); $destination = $shell_app.namespace(\"%ROOT%\"); $destination.Copyhere($zip_file.items())"
echo Expanding with powershell to: %AZURLANESCRIPT%
powershell -command "$shell_app=new-object -com shell.application; $zip_file = $shell_app.namespace(\"%FILE_DEST%\"); $destination = $shell_app.namespace(\"%AZURLANESCRIPT%\"); $destination.Copyhere($zip_file.items())"
) else (
echo "pythonpackage.zip already downloaded, delete to re-download"
pause > NUL
)
call %~dp0AzurLaneAutoScript/python-3.7.6.amd64/python.exe --version >nul
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo initializing uiautomator2..
%~dp0AzurLaneAutoScript/python-3.7.6.amd64/python.exe -m uiautomator2 init
call %PYTHON% -m uiautomator2 init
echo The installation was successful
echo Press any key to proceed
pause > NUL
goto menu
) else (
echo :: it was not possible to install uiautomator2, make sure you have a folder python-3.7.6.amd64
echo :: it was not possible to install uiautomator2
echo :: make sure you have a folder "python-3.7.6.amd64"
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
goto menu
)
goto menu
:: -----------------------------------------------------------------------------
:updater
SET GIT_ALAS=%~dp0python-3.7.6.amd64\Git\cmd\git.exe
SET GLP=%GIT_ALAS%
SET ALAS_PY=alas.py
if exist %ALAS_PY% (
goto updater_menu
) else (
cd AzurLaneAutoScript
echo.
goto updater_menu
)
:: -----------------------------------------------------------------------------
:updater_menu
cls
echo.
echo :: This update only will work if you downloaded ALAS with this file using option 2. clone
@ -207,49 +278,102 @@ goto menu
echo Press any key to return to the menu...
echo.
pause > NUL
goto updater
goto updater_menu
)
:: -----------------------------------------------------------------------------
:LmeSzinc
call git --version >nul
call %GLP% --version >nul
if %errorlevel% == 0 (
echo GIT Found! Proceeding..
echo Updating from LmeSzinc repository..
call git fetch origin master && git reset --hard origin/master && git pull --ff-only origin master
call %GLP% fetch origin master
call %GLP% reset --hard origin/master
call %GLP% pull --ff-only origin master
echo DONE!
echo Press any key to proceed
pause > NUL
goto updater_menu
) else (
echo :: Git not detected, maybe there was an installation issue, try opening another CMD window and type choco install git
echo :: Git not detected, maybe there was an installation issue
echo check if you have this directory:
echo AzurLaneAutoScript\python-3.7.6.amd64\Git\cmd
echo.
pause > NUL
)
:: timout
PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
goto updater
:: -----------------------------------------------------------------------------
:whoamikyo
call git --version >nul
call %GLP% --version >nul
if %errorlevel% == 0 (
echo GIT Found! Proceeding..
echo Updating from whoamikyo repository..
call git fetch whoamikyo master && git reset --hard whoamikyo/master && git pull --ff-only whoamikyo master
call %GLP% fetch whoamikyo master
call %GLP% reset --hard whoamikyo/master
call %GLP% pull --ff-only whoamikyo master
echo DONE!
echo Press any key to proceed
pause > NUL
goto updater_menu
) else (
echo :: Git not detected, maybe there was an installation issue, try opening another CMD window and type choco install git
echo.
echo :: Git not detected, maybe there was an installation issue
echo check if you have this directory:
echo AzurLaneAutoScript\python-3.7.6.amd64\Git\cmd
pause > NUL
goto updater_menu
)
:: timout
PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
goto updater
:: -----------------------------------------------------------------------------
:nightly
call git --version >nul
call %GLP% --version >nul
if %errorlevel% == 0 (
echo GIT Found! Proceeding..
echo Updating from whoamikyo nightly repository..
call git fetch whoamikyo nightly && git reset --hard whoamikyo/nightly && git pull --ff-only whoamikyo nightly
call %GLP% fetch whoamikyo nightly
call %GLP% reset --hard whoamikyo/nightly
call %GLP% pull --ff-only whoamikyo nightly
echo Press any key to proceed
pause > NUL
goto updater_menu
) else (
echo :: Git not detected, maybe there was an installation issue, try opening another CMD window and type choco install git
echo :: Git not detected, maybe there was an installation issue
echo check if you have this directory:
echo AzurLaneAutoScript\python-3.7.6.amd64\Git\cmd
echo.
pause > NUL
goto updater_menu
)
:: timout
PowerShell -Command "Start-Sleep -s 3" > nul 2>&1
goto updater
:: -----------------------------------------------------------------------------
rem :AddPath <pathToAdd>
rem ECHO %PATH% | FINDSTR /C:"%~1" > nul
rem IF ERRORLEVEL 1 (
rem REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v PATH /t REG_SZ /d "%PATH%;%~1" > nul 2>&1
rem IF ERRORLEVEL 0 (
rem ECHO Adding %1 . . . Success!
rem SET "PATH=%PATH%;%~1"
rem SET UPDATE=1
rem ) ELSE (
rem ECHO Adding %1 . . . FAILED. Run this script with administrator privileges.
rem )
rem ) ELSE (
rem ECHO Skipping %1 - Already in PATH
rem )
rem EXIT /b
:: -----------------------------------------------------------------------------
rem :KillExplorer
rem ECHO Your desktop is being restarted, please wait. . .
rem ping -n 5 127.0.0.1 > NUL 2>&1
rem ECHO Killing process Explorer.exe. . .
rem taskkill /f /im explorer.exe
rem ECHO.
rem ECHO Your desktop is now loading. . .
rem ping -n 5 127.0.0.1 > NUL 2>&1
rem ECHO.
rem ping -n 5 127.0.0.1 > NUL 2>&1
rem START explorer.exe
rem START explorer.exe %CD%
rem EXIT /b
:: -----------------------------------------------------------------------------

View File

@ -1,6 +1,8 @@
[English Quick Guide](doc%2FQuick_guide.md)
[English Readme](README_en.md) `Translation in progress`
[Download Easy Install-v2](https://github.com/LmeSzinc/AzurLaneAutoScript/raw/master/Easy_Install-V2.bat)
# AzurLaneAutoScript
Alas, an Azur Lane automation tool with GUI (Support CN, EN, JP, able to support other servers).

View File

@ -1,3 +1,7 @@
[English Quick Guide](doc%2FQuick_guide.md)
[Download Easy Install-v2](https://github.com/LmeSzinc/AzurLaneAutoScript/raw/master/Easy_Install-V2.bat)
# AzurLaneAutoScript
Alas, an Azur Lane automation tool with GUI (For CN server, can support other server).

View File

@ -1,7 +1,10 @@
@SETLOCAL EnableExtensions EnableDelayedExpansion
@echo off
title ALAS run
call adb kill-server > nul 2>&1
SET ADB=%~dp0python-3.7.6.amd64\Lib\site-packages\adbutils\binaries\adb.exe
SET PYTHON=%~dp0python-3.7.6.amd64\python.exe
call %ADB% kill-server > nul 2>&1
set SCREENSHOT_FOLDER=%~dp0screenshots
if not exist %SCREENSHOT_FOLDER% (
@ -34,7 +37,7 @@ REM
set /p ADB_PORT=<adb_port.ini
echo connecting at %ADB_PORT%
adb connect %ADB_PORT%
call %ADB% connect %ADB_PORT%
::echo initializing uiautomator2
::%~dp0python-3.7.6.amd64/python.exe -m uiautomator2 init
@ -77,24 +80,25 @@ goto alas
)
:en
call %~dp0python-3.7.6.amd64/python.exe --version >nul
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening alas_en.pyw...
%~dp0python-3.7.6.amd64/python.exe alas_en.pyw
call %PYTHON% alas_en.pyw
) else (
echo :: it was not possible to open alas_en.pyw, make sure you have a folder python-3.7.6.amd64
echo :: inside AzurLaneAutoScript folder.
echo.
pause > NUL
)
PowerShell -Command "Start-Sleep -s 10" > nul 2>&1
goto alas
:cn
call %~dp0python-3.7.6.amd64/python.exe --version >nul
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening alas_en.pyw...
%~dp0python-3.7.6.amd64/python.exe alas_cn.pyw
call %PYTHON% alas_cn.pyw
) else (
echo :: it was not possible to open alas_cn.pyw, make sure you have a folder python-3.7.6.amd64
echo :: inside AzurLaneAutoScript folder.
@ -103,11 +107,11 @@ goto alas
)
goto alas
:jp
call %~dp0python-3.7.6.amd64/python.exe --version >nul
call %PYTHON% --version >nul
if %errorlevel% == 0 (
echo Python Found! Proceeding..
echo Opening alas_en.pyw...
%~dp0python-3.7.6.amd64/python.exe alas_jp.pyw
call %PYTHON% alas_jp.pyw
) else (
echo :: it was not possible to open alas_jp.pyw, make sure you have a folder python-3.7.6.amd64
echo :: inside AzurLaneAutoScript folder.

View File

@ -18,7 +18,7 @@
* Then it will install everything and download ALAS
* Will be created a folder `AzurLaneAutoScript` in the directory you run `Easy_Install-V2.bat`
* To Run ALAS, just click in `alas.bat`
* to avoid connection errors it's recommended to configure your emulator port correctly in the `alas.bat` file, just open it with notepad and edit line 5, remove the `::` and configure with your emulator PORT, below you have more information on how to find your emulator PORT, READ ALL.
* to avoid connection errors it's recommended to configure your emulator port correctly, in `alas.bat` first start will be prompt to enter your HOST:PORT, just open it with notepad and edit line 5, remove the `::` and configure with your emulator PORT, below you have more information on how to find your emulator PORT, READ ALL.
* It probably doesn't work on windows 7, you can test it and if it doesn't work try manual installation, tested on Windows 10 x64 Version 2004.
# Manual installation method