From 1bc1c7910a0bd593fa57e44f41319ead4d34b6ba Mon Sep 17 00:00:00 2001 From: sesouthall Date: Wed, 3 Jun 2026 18:28:15 -0700 Subject: [PATCH] Add a switching time option to give the user's machine time to minimize, then pause, then unpause the next game. --- GameShuffler/Form1.Designer.cs | 27 +++++++++++++++++++++++++-- GameShuffler/Form1.cs | 13 +++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/GameShuffler/Form1.Designer.cs b/GameShuffler/Form1.Designer.cs index 604a297..964c144 100644 --- a/GameShuffler/Form1.Designer.cs +++ b/GameShuffler/Form1.Designer.cs @@ -49,6 +49,8 @@ namespace GameShuffler refreshButton = new Button(); stopButton = new Button(); label7 = new Label(); + label8 = new Label(); + switchingTimeTextBox = new TextBox(); SuspendLayout(); // // runningProcessesSelectionList @@ -124,7 +126,7 @@ namespace GameShuffler // label5 // label5.AutoSize = true; - label5.Location = new Point(465, 389); + label5.Location = new Point(456, 389); label5.Name = "label5"; label5.Size = new Size(77, 25); label5.TabIndex = 8; @@ -133,7 +135,7 @@ namespace GameShuffler // label6 // label6.AutoSize = true; - label6.Location = new Point(465, 426); + label6.Location = new Point(456, 426); label6.Name = "label6"; label6.Size = new Size(77, 25); label6.TabIndex = 9; @@ -169,11 +171,30 @@ namespace GameShuffler label7.TabIndex = 12; label7.Text = "Press PageUp to move to the next game"; // + // label8 + // + label8.AutoSize = true; + label8.Location = new Point(539, 389); + label8.Name = "label8"; + label8.Size = new Size(167, 25); + label8.TabIndex = 13; + label8.Text = "Switching time (ms)"; + // + // switchingTimeTextBox + // + switchingTimeTextBox.Location = new Point(710, 389); + switchingTimeTextBox.Name = "switchingTimeTextBox"; + switchingTimeTextBox.Size = new Size(50, 31); + switchingTimeTextBox.TabIndex = 14; + switchingTimeTextBox.Text = "100"; + // // Form1 // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 593); + Controls.Add(switchingTimeTextBox); + Controls.Add(label8); Controls.Add(label7); Controls.Add(stopButton); Controls.Add(refreshButton); @@ -208,5 +229,7 @@ namespace GameShuffler private Button refreshButton; private Button stopButton; private Label label7; + private Label label8; + private TextBox switchingTimeTextBox; } } \ No newline at end of file diff --git a/GameShuffler/Form1.cs b/GameShuffler/Form1.cs index acba2be..a90dfbf 100644 --- a/GameShuffler/Form1.cs +++ b/GameShuffler/Form1.cs @@ -49,6 +49,7 @@ namespace GameShuffler int minShuffleTime = 0; int maxShuffleTime = 0; + int switchingTime = 0; List gamesToShuffle = new List(); Process? currentGame = null; @@ -82,21 +83,31 @@ namespace GameShuffler if (!int.TryParse(minTimeTextBox.Text, out minShuffleTime) || minShuffleTime < 0) { MessageBox.Show("Minimum shuffle time must be a positive number"); + return; } if (!int.TryParse(maxTimeTextBox.Text, out maxShuffleTime) || maxShuffleTime < minShuffleTime) { MessageBox.Show("Maximum shuffle time must be a positive number greater than minimum shuffle time"); + return; + } + + if (!int.TryParse(switchingTimeTextBox.Text, out switchingTime) || switchingTime < 0) + { + MessageBox.Show("Switching time must be a positive number"); + return; } if (!RegisterHotKey(this.Handle, RemoveGameKeyId, 0x0000, RemoveGameKey)) { MessageBox.Show("Failed to initialize remove game key"); + return; } if (!RegisterHotKey(this.Handle, NextGameKeyId, 0x0000, NextGameKey)) { MessageBox.Show("Failed to initialize next game key"); + return; } foreach (var processString in runningProcessesSelectionList.CheckedItems) @@ -155,9 +166,11 @@ namespace GameShuffler if (currentGame != null && gamesToShuffle.Count > 1) { ShowWindow(currentGame.MainWindowHandle, 7); + Thread.Sleep(switchingTime/2); SuspendProcess(currentGame); } + Thread.Sleep(switchingTime/2); StartNewGame(); Thread.Sleep(rand.Next(minShuffleTime, maxShuffleTime)*1000);