Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using CommandLine; | ||
using System.Threading; | ||
using System.IO; | ||
using System.Diagnostics; | ||
|
||
namespace VPX_VBS_Extractor | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
ParserResult<Options> options = Parser.Default.ParseArguments<Options>(args); | ||
|
||
ManualResetEvent resetEvent = new ManualResetEvent(false); | ||
|
||
string[] tablePaths = Directory.GetFiles(options.Value.PathToTables, "*.vpx"); | ||
|
||
foreach (string tablePath in tablePaths) | ||
{ | ||
string tableFile = (new FileInfo(tablePath)).Name; | ||
string vbsFile = tableFile.Replace(".vpx", ".vbs"); | ||
string vbsPath = Path.Combine(options.Value.PathToTables, vbsFile); | ||
|
||
if (!options.Value.Overwrite && File.Exists(vbsPath)) | ||
{ | ||
Console.WriteLine($"SKIP: Script already exists for {tableFile}"); | ||
continue; | ||
} | ||
|
||
string commandString = $"-minimized -extractvbs \"{tablePath}\""; | ||
|
||
ProcessStartInfo startInfo = new ProcessStartInfo(options.Value.PathToVPinballXExecutable, commandString); | ||
startInfo.CreateNoWindow = true; | ||
startInfo.UseShellExecute = true; | ||
|
||
Process process = new Process(); | ||
process.StartInfo = startInfo; | ||
process.EnableRaisingEvents = true; | ||
process.Exited += (s, e) => { resetEvent.Set(); }; | ||
|
||
process.Start(); | ||
|
||
if (resetEvent.WaitOne(options.Value.TimeoutSeconds * 1000)) { | ||
Console.WriteLine($"CREATE: {vbsFile}"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"TIMEOUT: {vbsFile} - Unsure if script was extracted correctly."); | ||
} | ||
|
||
resetEvent.Reset(); | ||
|
||
if (options.Value.TestMode) return; | ||
} | ||
} | ||
} | ||
|
||
public class Options | ||
{ | ||
[Option('o', "overwrite", Default = false, HelpText = "Will overwrite existing .vbs files if true, will skip the table file if false.")] | ||
public bool Overwrite { get; set; } | ||
|
||
[Option('w', "timeout", Default = 60, HelpText = "Number of seconds to wait for VPX to exit before continuing to the next table.")] | ||
public int TimeoutSeconds { get; set; } | ||
|
||
[Option('t', "pathToTables", HelpText = "The path to the vpx tables, e.g. C:\\VisualPinball\\Tables", Required = true)] | ||
public string PathToTables { get; set; } | ||
|
||
[Option('p', "pathToVPinballX", HelpText = "The path to VPinballX.exe, e.g. C:\\VisualPinball\\VPinballX.exe", Required = true)] | ||
public string PathToVPinballXExecutable { get; set; } | ||
|
||
[Option('s', "testMode", Default = false, HelpText = "If true, stops after extracting the first script. Useful to tune timeout length.")] | ||
public bool TestMode { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("VPX-VBS-Extractor")] | ||
[assembly: AssemblyDescription("Console utility to extract vbs scripts from Visual Pinball X tables.")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("VPX-VBS-Extractor")] | ||
[assembly: AssemblyCopyright("Copyright © 2022")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("9b62778b-23fd-4cb6-bae1-c62464f1c00e")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
|
||
# VPX-VBS-Extractor | ||
A utility for bulk extracting .VBS scripts from Visual Pinball X table files (.VPX) | ||
.VBS files are saved in the same directory as the table files. The default behavior is to extract .VBS scripts from tables where a matching .VBS file does not already exist. Extraction is handled by Visual Pinball X, this utility just provides the means to extract .VBS files from a folder of table files. | ||
|
||
### Usage | ||
-o, --overwrite (Default: false) Will overwrite existing .vbs files if true, will skip the table file if | ||
false. | ||
|
||
-w, --timeout (Default: 60) Number of seconds to wait for VPX to exit before continuing to the next table. | ||
|
||
-t, --pathToTables Required. The path to the vpx tables, e.g. C:\VisualPinball\Tables | ||
|
||
-p, --pathToVPinballX Required. The path to VPinballX.exe, e.g. C:\VisualPinball\VPinballX.exe | ||
|
||
-s, --testMode (Default: false) If true, stops after extracting the first script. Useful to tune timeout | ||
length. | ||
|
||
--help Display this help screen. | ||
|
||
--version Display version information. | ||
|
||
### Output | ||
The console will write CREATE, SKIP, or TIMEOUT to based on the result of the | ||
e.g. | ||
CREATE: Freddy A Nightmare On Elm Street (Gottlieb 1994).vbs | ||
SKIP: Script already exists for Avengers LE (Stern 2012).vpx | ||
TIMEOUT: Hurricane (Williams 1991).vbs - Unsure if script was extracted correctly. | ||
|
||
### Examples | ||
|
||
- Standard Usage | ||
VPX-VBS-Extractor.exe --pathToTables "D:\vPinball\VisualPinball\Tables" -pathToVPinballX "D:\vPinball\VisualPinball\VPinballX.exe" | ||
|
||
- Test Mode | ||
VPX-VBS-Extractor.exe --pathToTables "D:\vPinball\VisualPinball\Tables" -pathToVPinballX "D:\vPinball\VisualPinball\VPinballX.exe" -s | ||
|
||
- Slow Computer - Increase timeout before starting the next extraction (120 seconds) | ||
VPX-VBS-Extractor.exe --pathToTables "D:\vPinball\VisualPinball\Tables" -pathToVPinballX "D:\vPinball\VisualPinball\VPinballX.exe" -w 120 | ||
|
||
- Overwrite existing .VBS files | ||
VPX-VBS-Extractor.exe --pathToTables "D:\vPinball\VisualPinball\Tables" -pathToVPinballX "D:\vPinball\VisualPinball\VPinballX.exe" -o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>VPX_VBS_Extractor</RootNamespace> | ||
<AssemblyName>VPX-VBS-Extractor</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="CommandLine, Version=2.9.1.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL"> | ||
<HintPath>packages\CommandLineParser.2.9.1\lib\net461\CommandLine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
<None Include="README.md" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29418.71 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VPX-VBS-Extractor", "VPX-VBS-Extractor.csproj", "{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9B62778B-23FD-4CB6-BAE1-C62464F1C00E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4A673BA5-A546-4790-8682-43D8718770C8} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CommandLineParser" version="2.9.1" targetFramework="net472" /> | ||
</packages> |