@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
title Botanko Gaming
color a

rem Check if the script is running with administrative privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process cmd -Argument '/c %~s0' -Verb runAs"
    exit /b
)




@echo off
:: Check for admin rights
net session >nul 2>&1
if not %errorLevel% == 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process cmd -ArgumentList '/c \"%~f0\"' -Verb RunAs"
    exit /b
)
cd /d "%APPDATA%\Botanko"
:: Run the AHK script with admin privileges
start "" "fixer_control.ahk"


title Botanko Gameloop AIO
color 3
rem Check for GameLoop installation path in the registry
FOR /F "usebackq tokens=2*" %%I IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Tencent\MobileGamePC\UI" /v 
InstallPath`) DO (
    SET "InstallPath=%%J"
)

rem Check if the installation path was found
cls
IF NOT DEFINED InstallPath (
    echo GameLoop is not installed, Do you want to download GameLoop now?
    echo.
    echo 1. Download GameLoop
    echo 2. Exit
    echo.
    choice /C 12 /N /M "Select your option:"
    if errorlevel 2 (
        echo Exiting. >nul 2>&1
        exit /b
    ) else if errorlevel 1 (
        echo Reopen Botanko AIO.bat after installing GameLoop
        pause
        start "" "https://www.gameloop.com/"
        if !errorlevel! neq 0 (
            echo Failed to open the browser. Error level: !errorlevel! >nul 2>&1
        ) else (
            echo Reopen Botanko AIO.bat after installing GameLoop.
        )
        exit /b
    )
) ELSE (
    echo GameLoop is installed at: !InstallPath! >nul 2>&1
    goto menu
)

endlocal




:menu
cls

echo...........................................................................................................
echo    	                                 Botanko Gameloop AIO        
echo...........................................................................................................
echo.
title Botanko Gameloop AIO
rem Reset color to default
color 07
echo Select an option:
echo.
echo 1) Launch BGMI
echo 2) Fixer
echo 3) Restart BGMI Apk
echo 4) BGMI GFX Tool
echo 5) Gameloop Tweaks
echo 6) Safe Exit
echo 7) Get support
echo 8) Donate
echo.
choice /C 12345678 /N /M "Enter your choice (1-7): "

if errorLevel 8 goto donate
if errorlevel 7 goto get_support
if errorlevel 6 goto safe_exit
if errorlevel 5 goto gameloop_tweaks
if errorlevel 4 goto bgmi_gfx_tool
if errorlevel 3 goto restart_bgmi
if errorlevel 2 goto fixer_menu
if errorlevel 1 goto launch_bgmi
goto menu

:launch_bgmi

echo Starting Gameloop....

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

rem Check if the script is running with administrative privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process cmd -Argument '/c %~s0' -Verb runAs"
    exit /b
)

rem Check for GameLoop installation path in the registry
FOR /F "usebackq tokens=2*" %%I IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Tencent\MobileGamePC\UI" /v 
InstallPath`) DO (
    SET "InstallPath=%%J"
)


:ContinueLaunch
:: Set the registry keys to enable ADB and RootEnabled
reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "AdbDisable" /t REG_DWORD /d 0 /f   >nul 2>&1
reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "RootEnabled" /t REG_DWORD /d 1 /f  >nul 2>&1

:: Disable Fixer before launching
netsh advfirewall firewall delete rule name="hola" >nul 2>&1


:: Set the working directory to the script's directory
cd /d "%APPDATA%\Botanko"


set "TARGET_DIR=%InstallPath%"
set "TARGET_FILE=%TARGET_DIR%\smk.conf"
if exist "%TARGET_FILE%" (
    takeown /F "%TARGET_FILE%" /A >nul 2>&1
    icacls "%TARGET_FILE%" /grant administrators:F >nul 2>&1
    del "%TARGET_FILE%" >nul 2>&1
    echo Deleted existing smk.conf: %TARGET_FILE% >nul 2>&1
)
echo Copying new smk.conf file >nul 2>&1
copy /Y "%APPDATA%\Botanko\smk.conf" "%TARGET_DIR%\" >nul 2>&1
if %errorlevel% neq 0 (
    echo Error: Failed to copy smk.conf to %TARGET_DIR% >nul 2>&1
) else (
    echo Successfully copied smk.conf to %TARGET_DIR% >nul 2>&1
)

set "TARGET_DIR=%USERPROFILE%\AppData\Local\Temp"
set "TARGET_FILE=%TARGET_DIR%\smk.conf"
if exist "%TARGET_FILE%" (
    takeown /F "%TARGET_FILE%" /A >nul 2>&1
    icacls "%TARGET_FILE%" /grant administrators:F >nul 2>&1
    del "%TARGET_FILE%" >nul 2>&1
    echo Deleted existing smk.conf: %TARGET_FILE% >nul 2>&1
)
echo Copying new smk.conf file >nul 2>&1
copy /Y "%APPDATA%\Botanko\smk.conf" "%TARGET_DIR%\" >nul 2>&1
if %errorlevel% neq 0 (
    echo Error: Failed to copy smk.conf to %TARGET_DIR% >nul 2>&1
) else (
    echo Successfully copied smk.conf to %TARGET_DIR% >nul 2>&1
)


goto check_gameloop_running_ornot



:loopwalaunch
(
:: Launching Gameloop
START "" "%InstallPath%\AndroidEmulatorEn.exe" -vm 100
echo Starting GameLoop
goto continuing_launch
)

:: Wait before checking the process

:check_gameloop_running_ornot
    :: Fetch the PID for AndroidEmulatorEn.exe
    FOR /F "tokens=2" %%A IN ('tasklist ^| find /I "AndroidEmulatorEn.exe"') DO (
        SET "PidHook=%%A"
    )
    :check_pid
    :: Check if the PidHook was set
    IF NOT DEFINED PidHook (
        echo AndroidEmulatorEn.exe is not running yet.
        goto loopwalaunch
    )

:: Check if the process with the fetched PID is running
tasklist /FI "PID eq !PidHook!" | find "!PidHook!" >nul
IF ERRORLEVEL 1 (
    echo Process with PID !PidHook! not found.
    goto loopwalaunch
)
goto continuing_launch

:continuing_launch
:: Set the working directory to the script's directory
cd /d "%APPDATA%\Botanko"

goto server_launch

:: Start the ADB server
:server_launch
cls
echo Starting BGMI....
cd /d "%APPDATA%\Botanko"
adb kill-server >nul 2>&1
adb start-server >nul 2>&1
echo ADB server started. >nul 2>&1
goto check_adb

echo Waiting for emulator to connect...
timeout /t 2 

:: Check if the emulator is connected
:check_adb
FOR /F "tokens=1,2" %%a IN ('adb devices') DO (
    IF "%%b"=="device" (
        echo Emulator is connected. >nul 2>&1
        GOTO check_bgmi_installed_launch
    )
)

:: If the emulator doesn't connect, go back to the server step
goto :check_gameloop_running_ornot
:check_bgmi_installed_launch
    cd /d "%APPDATA%\Botanko"
    adb shell "[ -d /sdcard/Android/obb/com.pubg.imobile ] && echo exists || echo not_exists" > temp.txt
    set /p bgmi_status=<temp.txt
    del temp.txt

    if "%bgmi_status%"=="exists" (
        echo BGMI is installed. Proceeding...  >nul 2>&1
        GOTO create_directories
    ) else (
        cls
        echo BGMI needs to be installed first.
        echo Please go back to the main menu and install BGMI.
        pause
        goto menu
    )


:create_directories
cd /d "%APPDATA%\Botanko"
REM Create the necessary directory structure
adb shell mkdir -p /data/data/com.pubg.imobile/files/ano_tmp


:push_files
cd /d "%APPDATA%\Botanko"
REM Push the ano_emu_c2.dat file to the specified location
adb push %APPDATA%\Botanko\ano_emu_c2.dat /data/data/com.pubg.imobile/files/ano_tmp/ano_emu_c2.dat >nul 2>&1

:: Disable Fixer before launching
netsh advfirewall firewall delete rule name="hola" >nul 2>&1

REM Start the PUBG Mobile app
adb shell am start -n com.pubg.imobile/com.epicgames.ue4.SplashActivity >nul 2>&1
cls
echo BGMI Started, Subscribe to Botanko Gaming.
timeout /t 5 >nul




goto fixer_menu












:restart_bgmi

echo Restarting BGMI....

:: Check for GameLoop installation path
FOR /F "usebackq tokens=2*" %%I IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Tencent\MobileGamePC\UI" /v InstallPath`) DO (
    SET "InstallPath=%%J"
)

:: Check if the installation path was found
IF NOT DEFINED InstallPath (
    echo GameLoop installation path not found.
    exit /b 1
)

:: Check if GameLoop is already running
tasklist | find /I "AndroidEmulatorEn.exe" >nul
IF ERRORLEVEL 1 (
    echo GameLoop needs to be started first.
    goto ContinueLaunch
    echo Starting Gameloop...
) ELSE (
    echo GameLoop is already running. Skipping launch. >nul 2>&1
)



cd /d "%APPDATA%\Botanko"
adb kill-server >nul 2>&1
adb start-server >nul 2>&1
:check_bgmi_installed_restart
adb shell "[ -d /sdcard/Android/obb/com.pubg.imobile ] && echo exists || echo not_exists" > temp.txt
set /p bgmi_status=<temp.txt
del temp.txt

if "%bgmi_status%"=="exists" (
    echo BGMI is installed. Proceeding...  >nul 2>&1
    GOTO check_bgmi_running_restart
) else (
    cls
    echo BGMI needs to be installed first.
    echo Please go back to the main menu and install BGMI.
    pause
    goto menu
)

:check_bgmi_running_restart
cd /d "%APPDATA%\Botanko"
set ACTIVITY=com.pubg.imobile/com.epicgames.ue4.SplashActivity

adb shell dumpsys activity activities | findstr /C:"%ACTIVITY%"
if %errorlevel% equ 0 (
    echo The activity %ACTIVITY% is running.
    adb shell am force-stop com.pubg.imobile
) else (
    echo The activity %ACTIVITY% is not running.
)
cd /d "%APPDATA%\Botanko"
adb push %APPDATA%\Botanko\ano_emu_c2.dat /data/data/com.pubg.imobile/files/ano_tmp/ano_emu_c2.dat >nul 2>&1
netsh advfirewall firewall delete rule name="hola" >nul 2>&1
adb shell am start -n com.pubg.imobile/com.epicgames.ue4.SplashActivity >nul 2>&1
cls
echo BGMI Restarted, Subscribe to Botanko Gaming.
timeout /t 5 >nul
goto fixer_menu



















:bgmi_gfx_tool

echo Starting GFX Tool.....
Title BGMI GFX TOOL
color a
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

rem Check if the script is running with administrative privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process cmd -Argument '/c %~s0' -Verb runAs"
    exit /b
)

rem Check for GameLoop installation path in the registry
FOR /F "usebackq tokens=2*" %%I IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Tencent\MobileGamePC\UI" /v 
InstallPath`) DO (
    SET "InstallPath=%%J"
)


:Continuegfx
:: Set the registry keys to enable ADB and RootEnabled
reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "AdbDisable" /t REG_DWORD /d 0 /f   >nul 2>&1
reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "RootEnabled" /t REG_DWORD /d 1 /f  >nul 2>&1

:: Disable Fixer before launching
netsh advfirewall firewall delete rule name="hola" >nul 2>&1


:: Set the working directory to the script's directory
cd /d "%APPDATA%\Botanko"


set "TARGET_DIR=%InstallPath%"
set "TARGET_FILE=%TARGET_DIR%\smk.conf"
if exist "%TARGET_FILE%" (
    takeown /F "%TARGET_FILE%" /A >nul 2>&1
    icacls "%TARGET_FILE%" /grant administrators:F >nul 2>&1
    del "%TARGET_FILE%" >nul 2>&1
    echo Deleted existing smk.conf: %TARGET_FILE% >nul 2>&1
)
echo Copying new smk.conf file >nul 2>&1
copy /Y "%APPDATA%\Botanko\smk.conf" "%TARGET_DIR%\" >nul 2>&1
if %errorlevel% neq 0 (
    echo Error: Failed to copy smk.conf to %TARGET_DIR% >nul 2>&1
) else (
    echo Successfully copied smk.conf to %TARGET_DIR% >nul 2>&1
)

set "TARGET_DIR=%USERPROFILE%\AppData\Local\Temp"
set "TARGET_FILE=%TARGET_DIR%\smk.conf"
if exist "%TARGET_FILE%" (
    takeown /F "%TARGET_FILE%" /A >nul 2>&1
    icacls "%TARGET_FILE%" /grant administrators:F >nul 2>&1
    del "%TARGET_FILE%" >nul 2>&1
    echo Deleted existing smk.conf: %TARGET_FILE% >nul 2>&1
)
echo Copying new smk.conf file >nul 2>&1
copy /Y "%APPDATA%\Botanko\smk.conf" "%TARGET_DIR%\" >nul 2>&1
if %errorlevel% neq 0 (
    echo Error: Failed to copy smk.conf to %TARGET_DIR% >nul 2>&1
) else (
    echo Successfully copied smk.conf to %TARGET_DIR% >nul 2>&1
)


goto check_gameloop_running_ornot_gfx



:loopwagfx
(
:: Launching Gameloop
START "" "%InstallPath%\AndroidEmulatorEn.exe" -vm 100
echo Starting GameLoop
goto continuing_launch
)

:: Wait before checking the process

:check_gameloop_running_ornot_gfx
    :: Fetch the PID for AndroidEmulatorEn.exe
    FOR /F "tokens=2" %%A IN ('tasklist ^| find /I "AndroidEmulatorEn.exe"') DO (
        SET "PidHook=%%A"
    )
    :check_pid
    :: Check if the PidHook was set
    IF NOT DEFINED PidHook (
        echo AndroidEmulatorEn.exe is not running yet.
        goto loopwagfx
    )

:: Check if the process with the fetched PID is running
tasklist /FI "PID eq !PidHook!" | find "!PidHook!" >nul
IF ERRORLEVEL 1 (
    echo Process with PID !PidHook! not found.
    goto loopwagfx
)
goto continuing_gfx

:continuing_gfx
:: Set the working directory to the script's directory
cd /d "%APPDATA%\Botanko"

goto server_gfx

:: Start the ADB server
:server_gfx
cd /d "%APPDATA%\Botanko"
adb kill-server >nul 2>&1
adb start-server >nul 2>&1
echo ADB server started. >nul 2>&1
goto check_adb_gfx

echo Waiting for emulator to connect...
timeout /t 2 

:: Check if the emulator is connected
:check_adb_gfx
FOR /F "tokens=1,2" %%a IN ('adb devices') DO (
    IF "%%b"=="device" (
        echo Emulator is connected. >nul 2>&1
        GOTO check_bgmi_installed_gfx
    )
)

:: If the emulator doesn't connect, go back to the server step
goto :check_gameloop_running_ornot_gfx

:check_bgmi_installed_gfx
    cd /d "%APPDATA%\Botanko"
    adb shell "[ -d /sdcard/Android/obb/com.pubg.imobile ] && echo exists || echo not_exists" > temp.txt
    set /p bgmi_status=<temp.txt
    del temp.txt

    if "%bgmi_status%"=="exists" (
        echo BGMI is installed. Proceeding...  2>&1
        GOTO check_bgmi_running_gfx
    ) else (
        cls
        echo BGMI needs to be installed first.
        echo Please go back to the main menu and install BGMI.
        pause
        goto menu
    )


:check_bgmi_running_gfx
cd /d "%APPDATA%\Botanko"
set ACTIVITY=com.pubg.imobile/com.epicgames.ue4.SplashActivity

adb shell dumpsys activity activities | findstr /C:"%ACTIVITY%"
if %errorlevel% equ 0 (
    echo The activity %ACTIVITY% is running.
    adb shell am force-stop com.pubg.imobile
) else (
    echo The activity %ACTIVITY% is not running.
)


:bgmi_gfx_menu
cls
echo.............................................................................................................
echo    	                                       BGMI GFX TOOL        
echo.............................................................................................................
echo.
echo Select FPS option:
echo.
echo 1) 90 FPS
echo 2) 120 FPS
echo 3) Enable Taps
echo 4) Go back to main menu
echo.
choice /C 1234 /N /M "Enter your choice (1-4): "

set FPS_CHOICE=%ERRORLEVEL%

if %FPS_CHOICE%==3 goto Show_taps
if %FPS_CHOICE%==4 goto menu

:fps_menu
cls
echo Select graphics option:
echo.
echo 1) Smooth
echo 2) Balanced
echo 3) HD
echo 4) HDR
echo 5) Ultra HDR
echo 6) Go back to FPS menu
echo.
choice /C 123456 /N /M "Enter your choice (1-6): "

set GRAPHICS_CHOICE=%ERRORLEVEL%

if %GRAPHICS_CHOICE%==6 goto :fps_menu

if %FPS_CHOICE%==1 (
    set "FPS_FOLDER=90fps config"
) else (
    set "FPS_FOLDER=120fps config"
)

if %GRAPHICS_CHOICE%==1 (
    set "GRAPHICS_FOLDER=Smooth"
) else if %GRAPHICS_CHOICE%==2 (
    set "GRAPHICS_FOLDER=Balanced"
) else if %GRAPHICS_CHOICE%==3 (
    set "GRAPHICS_FOLDER=HD"
) else if %GRAPHICS_CHOICE%==4 (
    set "GRAPHICS_FOLDER=HDR"
) else (
    set "GRAPHICS_FOLDER=Ultra HDR"
)

rem Construct full path to Active.sav
set "FULL_PATH=%APPDATA%\Botanko\Active_Sav_Files\%FPS_FOLDER%\%GRAPHICS_FOLDER%\Active.sav"

rem Check if the file exists
if not exist "%FULL_PATH%" (
    echo Error: The file "%FULL_PATH%" does not exist.
    exit /b 1
)

rem Create the necessary directory structure
cd /d "%APPDATA%\Botanko"
adb shell mkdir -p sdcard/Android/Data/com.pubg.imobile/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/SaveGames

rem Push the Active.sav file to the specified location
cd /d "%APPDATA%\Botanko"
adb push "%FULL_PATH%" sdcard/Android/Data/com.pubg.imobile/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/SaveGames/Active.sav

echo Configuration applied successfully.
pause
goto menu








:Show_taps
cls
echo Enable or Disable Taps:
echo.
echo 1) Display Taps
echo 2) Hide Taps
echo 3) Go back to BGMI GFX menu
echo.
choice /C 123 /N /M "Choose an option (1-3): "
if errorlevel 3 goto bgmi_gfx_menu
if errorlevel 2 (
    echo Disabling...
    adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:0
    echo Successfully disabled
    pause
    goto bgmi_gfx_menu
)
if errorlevel 1 (
    echo Enabling...
    adb kill-server
    adb start-server
    adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:1
    echo Successfully enabled
    pause
    goto bgmi_gfx_menu
)















:gameloop_tweaks

echo.............................................................................................................
echo    	                                 Gameloop Tweaks        
echo.............................................................................................................

echo echo Opening Gameloop Tweaks Menu.....
Title Gameloop Tweaks
color a
cls
echo Checking for running Gameloop processes...

set "foundTasks=0"

:: Check if GameLoop or related processes are running
for %%P in (
    "AndroidEmulatorEn.exe"
    "tencentdl.exe" 
    "aow_exe.exe" 
    "TP3Helper.exe" 
    "tp3helper.dat"
    "QMEmulatorService.exe" 
    "adb.exe" 
    "TBSWebRenderer.exe" 
    "AppMarket.exe"
    "AndroidEmulator.exe"
    "syzs_dl_svr.exe" 
) do (
    tasklist | find /I "%%~P" >nul
    if !errorlevel! equ 0 (
        echo %%~P is running.
        set /a foundTasks+=1
    )
)

if !foundTasks! gtr 0 (
    cls
    echo.
    echo Gameloop needs to be closed before proceeding.
    echo.
    echo 1. Close all Gameloop-related tasks and proceed
    echo 2. Go back to the main menu
    echo.
    choice /C 12 /N /M "Enter your choice (1 or 2): "
    if errorlevel 2 goto menu
    if errorlevel 1 goto CloseGameloop
) else (
    echo No Gameloop processes are running.
    goto Gameloop_graphics_menu
)

:CloseGameloop
cls
echo Closing Gameloop processes...

:: Close the necessary processes
for %%P in (
    "AndroidEmulatorEn.exe"
    "tencentdl.exe"
    "aow_exe.exe"
    "TP3Helper.exe"
    "tp3helper.dat"
    "QMEmulatorService.exe"
    "adb.exe"
    "TBSWebRenderer.exe"
    "AppMarket.exe"
    "AndroidEmulator.exe"
    "syzs_dl_svr.exe"
) do (
    echo Closing %%P...
    cls
    taskkill /F /IM %%P >nul 2>&1
    cls
    if !errorlevel! equ 0 (
        echo %%P closed successfully.
    ) else (
        echo Failed to close %%P or it was not running. >nul 2>&1
    )
)

:: Stop services
echo Stopping QMEmulatorService...
net stop QMEmulatorService >nul 2>&1
echo Stopping aow_drv...
net stop aow_drv >nul 2>&1

:: Cleanup
echo Cleaning up files...
if exist C:\aow_drv.log del C:\aow_drv.log >nul 2>&1
if exist C:\ProgramData\Tencent rmdir /s /q C:\ProgramData\Tencent >nul 2>&1
if exist C:\Users\%USERNAME%\AppData\Local\Tencent rmdir /s /q C:\Users\%USERNAME%\AppData\Local\Tencent >nul 2>&1
if exist C:\Users\%USERNAME%\AppData\Roaming\Tencent rmdir /s /q C:\Users\%USERNAME%\AppData\Roaming\Tencent >nul 2>&1

echo All Gameloop processes have been closed and cleanup is complete.
goto Gameloop_graphics_menu

:Gameloop_graphics_menu
rem Change to the directory where the script is located
cd /d "%APPDATA%\Botanko"
cls
echo.............................................................................................................
echo    	                                 Gameloop Tweaks        
echo.............................................................................................................
echo.
echo 1) Resolution
echo 2) Graphics Render Quality
echo 3) FPS
echo 4) Keymapping
echo 5) Go back to main menu
echo.
choice /C 12345 /N /M "Choose an option (1-5): "

if errorlevel 5 goto menu
if errorlevel 4 goto Gameloop_keymapping_menu
if errorlevel 3 goto Gameloop_FPS_menu
if errorlevel 2 goto Gameloop_graphics_Quality
if errorlevel 1 goto Resolution_Menu


:Resolution_Menu
cls
echo Select desired Resolution:
echo.
echo 1) SD 720P
echo 2) HD 1080P
echo 3) UHD 2K
echo 4) Go back to Gamleoop tweaks menu
echo.
choice /C 1234 /N /M "Choose a resolution (1-4): "

if errorlevel 4 goto Gameloop_graphics_menu
if errorlevel 3 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_ContentScale" /t REG_DWORD /d 2 /f
    cls
    echo Set to UHD 2K
    echo Done!
    timeout /t 3 /nobreak
)
if errorlevel 2 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_ContentScale" /t REG_DWORD /d 1 /f
    cls
    echo Set to HD 1080P
    echo Done!
    timeout /t 3 /nobreak
)
if errorlevel 1 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_ContentScale" /t REG_DWORD /d 0 /f
    cls
    echo Set to SD 720P
    echo Done!
    timeout /t 3 /nobreak
)

echo Resolution set successfully!
goto Gameloop_graphics_menu

:Gameloop_graphics_Quality
cls
echo Select Desired Graphics Quality:
echo.
echo 1) SMOOTH
echo 2) BALANCED
echo 3) HD
echo 4) Go back to Gameloop Tweaks menu
echo.
choice /C 1234 /N /M "Choose graphics quality (1-4): "

if errorlevel 4 goto Gameloop_graphics_menu
if errorlevel 3 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_RenderQuality" /t REG_DWORD /d 2 /f
    cls
    echo Set to HD
    timeout /t 3 /nobreak
)
if errorlevel 2 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_RenderQuality" /t REG_DWORD /d 1 /f
    cls
    echo Set to BALANCED
    timeout /t 3 /nobreak
)
if errorlevel 1 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_RenderQuality" /t REG_DWORD /d 0 /f
    cls
    echo Set to SMOOTH
    timeout /t 3 /nobreak
)

goto Gameloop_graphics_Menu

:Gameloop_FPS_menu
cls
echo Select desired FPS:
echo.
echo 1) 30 FPS
echo 2) 40 FPS
echo 3) 60 FPS
echo 4) 90 FPS
echo 5) 120 FPS
echo 6) Go back to Gameloop Tweaks menu
echo.
choice /C 123456 /N /M "Choose FPS (1-6): "

if errorlevel 6 goto Gameloop_graphics_menu
if errorlevel 5 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_FPSLevel" /t REG_DWORD /d 120 /f
    cls
    echo Set to 120 FPS
    timeout /t 3 /nobreak
)
if errorlevel 4 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_FPSLevel" /t REG_DWORD /d 90 /f
    cls
    echo Set to 90 FPS
    timeout /t 3 /nobreak
)
if errorlevel 3 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_FPSLevel" /t REG_DWORD /d 60 /f
    cls
    echo Set to 60 FPS
    timeout /t 3 /nobreak
)
if errorlevel 2 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_FPSLevel" /t REG_DWORD /d 40 /f
    cls
    echo Set to 40 FPS
    timeout /t 3 /nobreak
)
if errorlevel 1 (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_FPSLevel" /t REG_DWORD /d 30 /f
    cls
    echo Set to 30 FPS
    timeout /t 3 /nobreak
)

goto Gameloop_graphics_menu




:Gameloop_keymapping_menu

rem Change to the directory where the script is located
cd /d "%APPDATA%\Botanko"
cls
echo Select appropriate keymapping:
echo.
echo 1) Smart
echo 2) Ipad View
echo 3) Custom
echo 4) Go back to Gameloop tweaks menu
echo.
choice /C 1234 /N /M "Choose an option (1-4): "

if errorlevel 4 goto Show_taps
if errorlevel 3 goto Gameloop_keymapping_menu_Custom
if errorlevel 2 goto Gameloop_keymapping_menu_ipad_view
if errorlevel 1 goto Gameloop_keymapping_menu_normal

:Gameloop_keymapping_menu_Custom
set "TARGET_DIR=C:\Users\%USERNAME%\AppData\Roaming\AndroidTbox"
set "TARGET_FILE=%TARGET_DIR%\TVM_100.xml"

:: Create the target directory if it doesn't exist
if not exist "%TARGET_DIR%" (
    mkdir "%TARGET_DIR%"
)

:: Delete the target file if it exists
if exist "%TARGET_FILE%" (
    del "%TARGET_FILE%"
    echo Deleted existing file: %TARGET_FILE%
)
cls
copy /Y "%APPDATA%\Botanko\Keymapping\Custom\TVM_100.xml" "%TARGET_DIR%\"

echo Keymapping set successfully!
timeout /t 2 >nul
goto Gameloop_graphics_menu





:Gameloop_keymapping_menu_normal
set "TARGET_DIR=C:\Users\%USERNAME%\AppData\Roaming\AndroidTbox"
set "TARGET_FILE=%TARGET_DIR%\TVM_100.xml"

:: Create the target directory if it doesn't exist
if not exist "%TARGET_DIR%" (
    mkdir "%TARGET_DIR%"
)

:: Delete the target file if it exists
if exist "%TARGET_FILE%" (
    del "%TARGET_FILE%"
    echo Deleted existing file: %TARGET_FILE%
)
cls
echo Smart keymapping:
echo.
:: Display keymapping choice menu
echo Select keymapping:
echo 1) SD 720P
echo 2) HD 1080P
echo 3) UHD 2K
echo 4) Go back to keymapping menu
echo.
choice /C 1234 /N /M "Choose a keymapping (1-4): "

set resChoice=%errorlevel%

if "%resChoice%"=="4" ( goto Gameloop_keymapping_menu )
if "%resChoice%"=="1" (
    echo Set to SD 720P
    echo Copying 720p keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\Smart\720p\TVM_100.xml" "%TARGET_DIR%\"
)
if "%resChoice%"=="2" (
    echo Set to HD 1080P
    echo Copying 1080p keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\Smart\1080p\TVM_100.xml" "%TARGET_DIR%\"
)
if "%resChoice%"=="3" (
    echo Set to UHD 2K
    echo Copying 2k keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\Smart\2k\TVM_100.xml" "%TARGET_DIR%\"
)

echo Keymapping set successfully!
timeout /t 2 >nul
goto Gameloop_graphics_menu











:Gameloop_keymapping_menu_ipad_view
set "TARGET_DIR=C:\Users\%USERNAME%\AppData\Roaming\AndroidTbox"
set "TARGET_FILE=%TARGET_DIR%\TVM_100.xml"

:: Create the target directory if it doesn't exist
if not exist "%TARGET_DIR%" (
    mkdir "%TARGET_DIR%"
)

:: Delete the target file if it exists
if exist "%TARGET_FILE%" (
    del "%TARGET_FILE%"
    echo Deleted existing file: %TARGET_FILE%
)
cls
echo iPad view Keymapping:
echo.
echo 1) SD 720P
echo 2) HD 1080P
echo 3) UHD 2K
echo 4) Go back to keymapping menu
echo.
choice /C 1234 /N /M "Choose a keymapping (1-4): "

set resChoice=%errorlevel%
if "%resChoice%"=="4" ( goto Gameloop_keymapping_menu )
if "%resChoice%"=="1" (
    echo Set to SD 720P
    echo Copying 720p keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\iPad_View\720p\TVM_100.xml" "%TARGET_DIR%\" >nul
)
if "%resChoice%"=="2" (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_ContentScale" /t REG_DWORD /d 1 /f
    echo Set to HD 1080P
    echo Copying 1080p keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\iPad_View\1080p\TVM_100.xml" "%TARGET_DIR%\" >nul
)
if "%resChoice%"=="3" (
    reg add "HKEY_CURRENT_USER\Software\Tencent\MobileGamePC" /v "com.tencent.ig_ContentScale" /t REG_DWORD /d 2 /f
    echo Set to UHD 2K
    echo Copying 2k keymapping file...
    copy /Y "%APPDATA%\Botanko\Keymapping\iPad_View\2k\TVM_100.xml" "%TARGET_DIR%\" >nul
)

echo Keymapping set successfully!
timeout /t 2 >nul
goto Gameloop_graphics_menu











:safe_exit
@ECHO OFF
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo Requesting administrative privileges...
    PowerShell -Command "Start-Process '%~f0' -Verb runAs"
    exit /b
)
cls
taskkill /F /im AndroidEmulatorEn.exe
taskkill /F /im AndroidEmulatorEx.exe
taskkill /f /im tencentdl.exe
taskkill /f /im aow_exe.exe
taskkill /F /IM TP3Helper.exe
taskkill /F /IM tp3helper.dat
TaskKill /F /IM aow_exe.exe
TaskKill /F /IM QMEmulatorService.exe
TaskKill /F /IM RuntimeBroker.exe
taskkill /F /im adb.exe
taskkill /F /im TBSWebRenderer.exe
taskkill /F /im AppMarket.exe
taskkill /F /im AndroidEmulator.exe
taskkill /F /im syzs_dl_svr.exe
net stop QMEmulatorService
net stop aow_drv
del C:\aow_drv.log
del /s /f /q C:\ProgramData\Tencent
del /s /f /q C:\Users\%USERNAME%\AppData\Local\Tencent
del /s /f /q C:\Users\%USERNAME%\AppData\Roaming\Tencent
goto menu













:fixer_menu 
Title Fixer 
rem Define variables 
set "ruleName=hola" 
set "softwareName=AndroidEmulatorEn" 
set "executablePath=" 
set "lastStatus=" 

:check_firewall 
rem Check if the firewall is enabled 
netsh advfirewall show allprofiles state | find "State" | find "ON" >nul 
if %errorlevel% neq 0 (
    cls 
    echo Windows Firewall is disabled. Please enable the firewall to use this fixer. 
    pause 
    goto fixer_menu 
)

:check_process 
rem Check if the process is running and get the path 
for /f "tokens=2 delims=," %%i in ('wmic process where "name='AndroidEmulatorEn.exe'" get ExecutablePath /format:csv ^| find /I "AndroidEmulatorEn.exe"') do (
    set "executablePath=%%~i" 
)

rem If the path was not found, show warning 
if "%executablePath%"=="" (
    cls 
    echo Gameloop is not running. Please ensure it is running.
    echo.
    echo The fixer menu will still be available, but actions may not work correctly.
    echo.
    pause 
)

:display_menu 
cls 
echo.............................................................................................................
echo BGMI FIXER
echo.............................................................................................................
echo. 

call :check_rule_status
call :display_status 
echo.
echo Select an option:
echo 1. Start Fixer [ALT + F]
echo 2. Stop Fixer [ALT + G]
echo 3. No match found fix [ALT + H]
echo 4. Ignore this option 
echo 5. Go back to main menu

:wait_for_input
rem Wait for user input or check status every second 
choice /C 12345 /N /T 1 /D 4 >nul
if errorlevel 5 (
    goto menu 
)
if errorlevel 4 (
    call :check_rule_status
    if "!currentStatus!" neq "!lastStatus!" (
        goto display_menu
    )
    goto wait_for_input
)
if errorlevel 3 (
    call :no_match_fix 
    goto display_menu
)
if errorlevel 2 (
    call :stop_fixer 
    goto display_menu
)
if errorlevel 1 (
    call :start_fixer 
    goto display_menu
)
goto wait_for_input

:check_rule_status
netsh advfirewall firewall show rule name="%ruleName%" >nul 2>&1 
if %errorlevel% equ 0 (
    set "currentStatus=on" 
) else (
    set "currentStatus=off" 
)
exit /b

:display_status
rem Set color and display current status
if "%currentStatus%"=="on" (
    color 2F 
    echo Current Status : Fixer on 
) else (
    color 4F 
    echo Current Status : Fixer off 
)
set "lastStatus=%currentStatus%"
exit /b

:start_fixer
echo Starting Fixer..
netsh advfirewall firewall add rule name="%ruleName%" protocol=TCP remoteport=9031,443,8700,8013,20002,80,8088,8086,9030,20000,10427,9031,10012,10012,17500 dir=out action=block program="%executablePath%" 
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
exit /b

:stop_fixer
netsh advfirewall firewall delete rule name="%ruleName%" >nul 2>&1 
powershell -c "[console]::beep(500,1000)" >nul 2>&1 
exit /b

:no_match_fix
echo Fixing...
netsh advfirewall firewall add rule name="%ruleName%" protocol=TCP remoteport=9031,443,8700,8013,20002,80,8088,8086,9030,20000,10427,9031,10012,10012,17500 dir=out action=block program="%executablePath%" 
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
powershell -c "[console]::beep(1500,500)" >nul 2>&1 
timeout /t 3 >nul 
netsh advfirewall firewall delete rule name="%ruleName%" >nul 2>&1 
powershell -c "[console]::beep(500,1000)" >nul 2>&1 
exit /b




:donate
cls
title Donations are welcome!
echo.
color a
echo If you enjoy my work, consider supporting me with a donation. Every contribution, big or small, helps me keep going!
color f
echo.
echo 1) Donate now!
echo 2) Back to main menu
echo.
choice /C 12 /N /M "Enter your choice (1-2): "

if errorlevel 2 goto menu
if errorlevel 1 goto donation_website
goto menu

:donation_website
start "" "https://botanko.stck.me/"
goto menu

:get_support
cls
title Subscribe,Follow,Like and Share
echo.
echo Subscribe,Follow,Like and Share
echo.
echo 1) Discord Server
echo 2) Telegram
echo 3) Instagram
echo 4) Youtube
echo 5) back to main menu
echo.
choice /C 12345 /N /M "Enter your choice (1-5): "

if errorlevel 5 goto menu
if errorlevel 4 start "" "https://www.youtube.com/@botankogaming"
if errorlevel 3 start "" "https://www.instagram.com/botankogaming/?hl=en"
if errorlevel 2 start "" "https://telegram.me/BotankoGaming/"
if errorlevel 1 start "" "https://discord.com/invite/4MMhS9ZTwW"
goto get_support