@echo off
setlocal
title Hyperplex Voice - Push-to-Talk Setup
echo ============================================
echo   Hyperplex Voice - Push-to-Talk helper
echo ============================================
echo.

where pythonw >nul 2>&1
if %errorlevel% neq 0 (
  echo Python isn't installed. I'll open the download page.
  echo Install Python, TICK "Add Python to PATH", then run this file again.
  start https://www.python.org/downloads/
  pause
  exit /b
)

echo Installing components...
python -m pip install --user --quiet websockets==12.0 pynput

set "DEST=%LOCALAPPDATA%\Hyperplex"
if not exist "%DEST%" mkdir "%DEST%"

echo Downloading the helper...
powershell -Command "Invoke-WebRequest -Uri 'https://hyperplexguild.com/ptt/hyperplex-ptt.py' -OutFile '%DEST%\hyperplex-ptt.py'"

echo Setting it to start with Windows...
set "STARTUP=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"
powershell -Command "$w=New-Object -ComObject WScript.Shell; $s=$w.CreateShortcut('%STARTUP%\HyperplexPTT.lnk'); $s.TargetPath='pythonw'; $s.Arguments='\"%DEST%\hyperplex-ptt.py\"'; $s.WindowStyle=7; $s.Save()"

echo Starting it now...
start "" pythonw "%DEST%\hyperplex-ptt.py"

echo.
echo  Done. The helper is running and starts with Windows.
echo  Open https://hyperplexguild.com/voice - the in-game PTT box turns green,
echo  then click "Set global key" to pick your key or mouse button.
echo.
pause
