Skip to content

Commit

Permalink
Changed Python to Batch
Browse files Browse the repository at this point in the history
Changed the script from Python to Batch.
Added window positioning feature.
  • Loading branch information
Niloqui committed Nov 24, 2024
1 parent b4ebbd0 commit 7cf3392
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 51 deletions.
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# SpideyPC_low_volume
The Spider-Man 2000 PC port has some issues on modern computers, one of them is the audio system. The game is very loud and tabbing out will make you permanently lose control of the game, so there is no way to lower the game volume using the Audio Mixer.
This little script solve this problem by automatically changing the volume of the game after booting it up.

This script was mase using Python 3.9.8.

# SpideyPC_starting_script
The Spider-Man 2000 PC port has some issues on modern computers.
The game is very loud and tabbing out will make you permanently lose control of the game, so there is no way to lower the game volume using the Audio Mixer.
Also, when using dgVoodoo to play this game, you can't position the game window whenever you want, you are forced to use top left corner or center of the screen.
This little script solve these two problems by automatically changing the volume of the game and moving the window after booting the game up.

# How to use
You can either use the .py script with Python or use the .exe export made using pyinstaller ( https://pyinstaller.org/en/stable/ )

You need to download NirCmd to make this script work: https://www.nirsoft.net/utils/nircmd.html
Both 32-bit and 64-bit work. You can extract NirCmd anywhere on your computer.

The **.exe** *(or the **.py**)* and the **.json** file must be put in the same directory of SpideyPC.exe.
Just copy the **.bat** file in the game directory (same folder of SpideyPC.exe).

Simply launch the **.exe** *(or the **.py**)* to start game with a lowered volume.
Simply launch the **.bat** to start game with a lowered volume. You **need** to set up a few variables before launching the script.


# How to config
Here is a description of all the configurations in *SpideyPC_low_volume_config.json*:
- **"Volume"**: The volume percentage that the game will use. Values can go from 0 to 1. The value must be a string, so do not eliminate the quotation marks. Default: *"0.10"*
- **"nircmdc path"**: Path to NirCmd .exe file. Default: *my path, so please set this correctly for yourself*
- **"Sleep time in seconds"**: Time before the volume gets lowered. Without this value, the script doesn't work. Default: *3*
- **"Keep command prompt window open"**: Keep the command prompt window open at the end. Default: *false*

All the variables are in the **.bat** file. Open the file with any text editor to modify it.

Here is a description of all the configurations in *SpideyPC_starting_script.bat*:
- **nircmd_path**: Path to NirCmd .exe file. Default: *my path, so please set this correctly for yourself*
- **sleep_time**: Time before the volume gets lowered (in seconds). Without this value, the script doesn't work. Default: *5*
- **set_volume**: If true, the script will lower the volume of the game. Default: *true*
- **volume**: The volume that the game will use. Values can go from 0 to 1. Default: *0.10*
- **set_position**: If true, the script will move the game window. Default: *true*
- **position_x** and **position_y**: Where the game will be at the end of the script. These values referes to the position of the top left corner of the window. Default: *320* and *30*
- **window_width** and **window_height**: These two values are only needed for the nircmd command to work, dgVoodoo will determine the game resolution. Default: *1280* and *960*
- **keep_window_open**: Keep the command prompt window open at the end. Default: *false*
28 changes: 0 additions & 28 deletions SpideyPC_low_volume.py

This file was deleted.

6 changes: 0 additions & 6 deletions SpideyPC_low_volume_config.json

This file was deleted.

1 change: 0 additions & 1 deletion SpideyPC_low_volume_exe_creator.txt

This file was deleted.

60 changes: 60 additions & 0 deletions SpideyPC_starting_script.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::: Configs
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Please set nircmd path properly
set nircmd_path=C:\Speedrun\__Utilities\nircmd-x64\nircmdc.exe

set sleep_time=5 & :: Default: 5 seconds

set "set_volume=true" & :: Default: true
set volume=0.10 & :: Default: 0.10

set "set_position=true" & :: Default: true

:: These values will be ignored if "CenterAppWindow = true" in dgVoodoo.conf
set position_x=320 & :: Default: 320
set position_y=30 & :: Default: 30

:: These values are only needed because the nircmd command to set the window position also needs
:: two values for width and height.
:: The settings in dgVoodoo.conf will be used for the resolution
set window_width=1280 & :: Default: 1280
set window_height=960 & :: Default: 960

set "keep_window_open=false" & :: Default: false



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::: Script
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

for /f "tokens=6" %%f in ('powershell Start-Process SpideyPC.exe -passthru') do (
set ppid=%%f
)

timeout /T %sleep_time% /nobreak

echo pid=%ppid%

if "%set_volume%" == "true" (
echo Volume = %volume%
%nircmd_path% setappvolume /%ppid% %volume%
)

if "%set_position%" == "true" (
echo Setting window position:
echo x = %position_x%
echo y = %position_y%
%nircmd_path% win setsize process /%ppid% %position_x% %position_y% %window_width% %window_height%
)

if "%keep_window_open%" == "true" (
%PAUSE
)



0 comments on commit 7cf3392

Please sign in to comment.