Browse Source

feature: system audio volume control

HOME 3 weeks ago
parent
commit
c3508c8549
5 changed files with 336 additions and 168 deletions
  1. 63 0
      Interops/SystemAudioVolumeInterop.cs
  2. 219 164
      MainForm.Designer.cs
  3. 41 4
      MainForm.cs
  4. 12 0
      MainForm.resx
  5. 1 0
      SinMaiLauncher.csproj

+ 63 - 0
Interops/SystemAudioVolumeInterop.cs

@@ -0,0 +1,63 @@
+using System.Reflection.PortableExecutable;
+using System.Runtime.InteropServices;
+using NAudio.CoreAudioApi;
+
+namespace SinMaiLauncher.Interops
+{
+    public class SystemAudioVolumeInterop
+    {
+        /// <summary>
+        /// 设置系统音量(0-100)
+        /// </summary>
+        /// <param name="value">音量百分比,范围 0-100</param>
+        /// <returns>是否成功</returns>
+        public static bool SetVolume(float value)
+        {
+            try
+            {
+                var setValue = value / 100f;
+
+                // 创建 MMDeviceEnumerator 来访问音频设备
+                using var enumerator = new MMDeviceEnumerator();
+                // 获取默认音频输出设备
+                using var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
+                // 获取 AudioEndpointVolume 对象
+                using var volume = device.AudioEndpointVolume;
+
+                volume.MasterVolumeLevelScalar = setValue;
+
+                return true;
+            }
+            catch (Exception)
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 获取当前系统音量(0-100)
+        /// </summary>
+        /// <returns>音量百分比,失败时返回 -1</returns>
+        public static float? GetVolume()
+        {
+            try
+            {
+                // 创建 MMDeviceEnumerator 来访问音频设备
+                using var enumerator = new MMDeviceEnumerator();
+                // 获取默认音频输出设备
+                using var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
+                // 获取 AudioEndpointVolume 对象
+                using var volume = device.AudioEndpointVolume;
+
+                // 获取当前音量 (0.0f 到 1.0f)
+                var currentVolume = volume.MasterVolumeLevelScalar;
+
+                return (int)(currentVolume * 100);
+            }
+            catch (Exception e)
+            {
+                return null;
+            }
+        }
+    }
+}

+ 219 - 164
MainForm.Designer.cs

@@ -44,23 +44,29 @@
             Label label7;
             Label label10;
             Label label13;
-            groupBox2 = new GroupBox();
-            btnProcessLoopBackVirtualNic = new Button();
-            lblProcessLoopBackVirtualNic = new Label();
-            groupBox10 = new GroupBox();
-            chkExplorerAuto = new CheckBox();
-            btnExplorerRestore = new Button();
-            btnExplorerKill = new Button();
-            groupBox11 = new GroupBox();
-            btnAppDataOverwrite = new Button();
-            groupBox9 = new GroupBox();
-            label14 = new Label();
+            GroupBox groupBox9;
+            TabPage tpUtils1;
+            GroupBox groupBox1;
+            TabPage tpUtils2;
             cboAimeCard = new SinMaiLauncher.CustomControls.AimeComboBox();
             btnAimeRefresh = new Button();
             btnAimeWrite = new Button();
+            lblSysVolume = new Label();
+            label16 = new Label();
+            btnSysVolumeDec = new Button();
+            btnSysVolumeInc = new Button();
             groupBox7 = new GroupBox();
             chkWinTrickAuto = new CheckBox();
             btnWinTrick = new Button();
+            groupBox10 = new GroupBox();
+            chkExplorerAuto = new CheckBox();
+            btnExplorerRestore = new Button();
+            btnExplorerKill = new Button();
+            groupBox2 = new GroupBox();
+            btnProcessLoopBackVirtualNic = new Button();
+            lblProcessLoopBackVirtualNic = new Label();
+            groupBox11 = new GroupBox();
+            btnAppDataOverwrite = new Button();
             groupBox3 = new GroupBox();
             lblPidMaria = new Label();
             lblSubControlMaria = new Label();
@@ -86,8 +92,6 @@
             lblMainControlStatus = new Label();
             tcMain = new TabControl();
             tpMainControl = new TabPage();
-            tpAimeCard = new TabPage();
-            tpUtils = new TabPage();
             tpMisc = new TabPage();
             tpSubControls = new TabPage();
             tpConsoles = new TabPage();
@@ -114,19 +118,24 @@
             label7 = new Label();
             label10 = new Label();
             label13 = new Label();
-            groupBox2.SuspendLayout();
-            groupBox10.SuspendLayout();
-            groupBox11.SuspendLayout();
+            groupBox9 = new GroupBox();
+            tpUtils1 = new TabPage();
+            groupBox1 = new GroupBox();
+            tpUtils2 = new TabPage();
             groupBox9.SuspendLayout();
+            tpUtils1.SuspendLayout();
+            groupBox1.SuspendLayout();
+            tpUtils2.SuspendLayout();
             groupBox7.SuspendLayout();
+            groupBox10.SuspendLayout();
+            groupBox2.SuspendLayout();
+            groupBox11.SuspendLayout();
             groupBox3.SuspendLayout();
             groupBox6.SuspendLayout();
             groupBox4.SuspendLayout();
             groupBox8.SuspendLayout();
             tcMain.SuspendLayout();
             tpMainControl.SuspendLayout();
-            tpAimeCard.SuspendLayout();
-            tpUtils.SuspendLayout();
             tpMisc.SuspendLayout();
             tpSubControls.SuspendLayout();
             tpConsoles.SuspendLayout();
@@ -271,37 +280,154 @@
             label13.TabIndex = 1;
             label13.Text = "还没做!";
             // 
-            // groupBox2
+            // groupBox9
             // 
-            groupBox2.Controls.Add(btnProcessLoopBackVirtualNic);
-            groupBox2.Controls.Add(label11);
-            groupBox2.Controls.Add(lblProcessLoopBackVirtualNic);
-            groupBox2.Controls.Add(label9);
-            groupBox2.Location = new Point(8, 6);
-            groupBox2.Name = "groupBox2";
-            groupBox2.Size = new Size(271, 70);
-            groupBox2.TabIndex = 2;
-            groupBox2.TabStop = false;
-            groupBox2.Text = "网络环境:这破玩意儿需要本机有一个IP地址";
+            groupBox9.Controls.Add(cboAimeCard);
+            groupBox9.Controls.Add(btnAimeRefresh);
+            groupBox9.Controls.Add(btnAimeWrite);
+            groupBox9.Location = new Point(8, 6);
+            groupBox9.Name = "groupBox9";
+            groupBox9.Size = new Size(333, 70);
+            groupBox9.TabIndex = 9;
+            groupBox9.TabStop = false;
+            groupBox9.Text = "Aime卡:帮你写进aime.txt";
             // 
-            // btnProcessLoopBackVirtualNic
+            // cboAimeCard
             // 
-            btnProcessLoopBackVirtualNic.Location = new Point(6, 22);
-            btnProcessLoopBackVirtualNic.Name = "btnProcessLoopBackVirtualNic";
-            btnProcessLoopBackVirtualNic.Size = new Size(45, 45);
-            btnProcessLoopBackVirtualNic.TabIndex = 0;
-            btnProcessLoopBackVirtualNic.Text = "处理";
-            btnProcessLoopBackVirtualNic.UseVisualStyleBackColor = true;
-            btnProcessLoopBackVirtualNic.Click += btnProcessLoopBackVirtualNic_Click;
+            cboAimeCard.FormattingEnabled = true;
+            cboAimeCard.Location = new Point(97, 22);
+            cboAimeCard.MaxLength = 24;
+            cboAimeCard.Name = "cboAimeCard";
+            cboAimeCard.Size = new Size(195, 25);
+            cboAimeCard.TabIndex = 10;
             // 
-            // lblProcessLoopBackVirtualNic
+            // btnAimeRefresh
             // 
-            lblProcessLoopBackVirtualNic.AutoSize = true;
-            lblProcessLoopBackVirtualNic.Location = new Point(107, 44);
-            lblProcessLoopBackVirtualNic.Name = "lblProcessLoopBackVirtualNic";
-            lblProcessLoopBackVirtualNic.Size = new Size(44, 17);
-            lblProcessLoopBackVirtualNic.TabIndex = 3;
-            lblProcessLoopBackVirtualNic.Text = "待检测";
+            btnAimeRefresh.Location = new Point(6, 22);
+            btnAimeRefresh.Name = "btnAimeRefresh";
+            btnAimeRefresh.Size = new Size(86, 42);
+            btnAimeRefresh.TabIndex = 2;
+            btnAimeRefresh.Text = "读取数据库";
+            btnAimeRefresh.UseVisualStyleBackColor = true;
+            btnAimeRefresh.Click += btnAimeRefresh_Click;
+            // 
+            // btnAimeWrite
+            // 
+            btnAimeWrite.Location = new Point(298, 10);
+            btnAimeWrite.Name = "btnAimeWrite";
+            btnAimeWrite.Size = new Size(29, 54);
+            btnAimeWrite.TabIndex = 2;
+            btnAimeWrite.Text = "写";
+            btnAimeWrite.UseVisualStyleBackColor = true;
+            btnAimeWrite.Click += btnAimeWrite_Click;
+            // 
+            // tpUtils1
+            // 
+            tpUtils1.Controls.Add(groupBox1);
+            tpUtils1.Controls.Add(groupBox9);
+            tpUtils1.Location = new Point(4, 26);
+            tpUtils1.Name = "tpUtils1";
+            tpUtils1.Padding = new Padding(3);
+            tpUtils1.Size = new Size(716, 127);
+            tpUtils1.TabIndex = 5;
+            tpUtils1.Text = "实用工具1";
+            tpUtils1.UseVisualStyleBackColor = true;
+            // 
+            // groupBox1
+            // 
+            groupBox1.Controls.Add(lblSysVolume);
+            groupBox1.Controls.Add(label16);
+            groupBox1.Controls.Add(btnSysVolumeDec);
+            groupBox1.Controls.Add(btnSysVolumeInc);
+            groupBox1.Location = new Point(347, 6);
+            groupBox1.Name = "groupBox1";
+            groupBox1.Size = new Size(333, 70);
+            groupBox1.TabIndex = 9;
+            groupBox1.TabStop = false;
+            groupBox1.Text = "系统音量:在杀死资源管理器的情况下方便调节";
+            // 
+            // lblSysVolume
+            // 
+            lblSysVolume.AutoSize = true;
+            lblSysVolume.Location = new Point(70, 25);
+            lblSysVolume.Name = "lblSysVolume";
+            lblSysVolume.Size = new Size(13, 17);
+            lblSysVolume.TabIndex = 12;
+            lblSysVolume.Text = "-";
+            // 
+            // label16
+            // 
+            label16.AutoSize = true;
+            label16.Location = new Point(6, 25);
+            label16.Name = "label16";
+            label16.Size = new Size(68, 17);
+            label16.TabIndex = 11;
+            label16.Text = "当前音量:";
+            // 
+            // btnSysVolumeDec
+            // 
+            btnSysVolumeDec.Location = new Point(141, 22);
+            btnSysVolumeDec.Name = "btnSysVolumeDec";
+            btnSysVolumeDec.Size = new Size(84, 42);
+            btnSysVolumeDec.TabIndex = 2;
+            btnSysVolumeDec.Text = "调小";
+            btnSysVolumeDec.UseVisualStyleBackColor = true;
+            btnSysVolumeDec.Click += btnSysVolumeDec_Click;
+            // 
+            // btnSysVolumeInc
+            // 
+            btnSysVolumeInc.Location = new Point(240, 22);
+            btnSysVolumeInc.Name = "btnSysVolumeInc";
+            btnSysVolumeInc.Size = new Size(87, 42);
+            btnSysVolumeInc.TabIndex = 2;
+            btnSysVolumeInc.Text = "调大";
+            btnSysVolumeInc.UseVisualStyleBackColor = true;
+            btnSysVolumeInc.Click += btnSysVolumeInc_Click;
+            // 
+            // tpUtils2
+            // 
+            tpUtils2.Controls.Add(groupBox7);
+            tpUtils2.Controls.Add(groupBox10);
+            tpUtils2.Location = new Point(4, 26);
+            tpUtils2.Name = "tpUtils2";
+            tpUtils2.Padding = new Padding(3);
+            tpUtils2.Size = new Size(716, 127);
+            tpUtils2.TabIndex = 1;
+            tpUtils2.Text = "实用工具2";
+            tpUtils2.UseVisualStyleBackColor = true;
+            // 
+            // groupBox7
+            // 
+            groupBox7.Controls.Add(chkWinTrickAuto);
+            groupBox7.Controls.Add(btnWinTrick);
+            groupBox7.Location = new Point(6, 6);
+            groupBox7.Name = "groupBox7";
+            groupBox7.Size = new Size(263, 70);
+            groupBox7.TabIndex = 3;
+            groupBox7.TabStop = false;
+            groupBox7.Text = "窗口调整:启动之后窗口可能会乱跳";
+            // 
+            // chkWinTrickAuto
+            // 
+            chkWinTrickAuto.AutoSize = true;
+            chkWinTrickAuto.Checked = true;
+            chkWinTrickAuto.CheckState = CheckState.Checked;
+            chkWinTrickAuto.Location = new Point(76, 33);
+            chkWinTrickAuto.Name = "chkWinTrickAuto";
+            chkWinTrickAuto.Size = new Size(99, 21);
+            chkWinTrickAuto.TabIndex = 6;
+            chkWinTrickAuto.Text = "保持自动调整";
+            chkWinTrickAuto.UseVisualStyleBackColor = true;
+            // 
+            // btnWinTrick
+            // 
+            btnWinTrick.Location = new Point(6, 20);
+            btnWinTrick.Name = "btnWinTrick";
+            btnWinTrick.Size = new Size(64, 44);
+            btnWinTrick.TabIndex = 2;
+            btnWinTrick.Text = "调整";
+            btnWinTrick.UseVisualStyleBackColor = true;
+            btnWinTrick.Click += btnWinTrick_Click;
             // 
             // groupBox10
             // 
@@ -348,6 +474,38 @@
             btnExplorerKill.UseVisualStyleBackColor = true;
             btnExplorerKill.Click += btnExplorerKill_Click;
             // 
+            // groupBox2
+            // 
+            groupBox2.Controls.Add(btnProcessLoopBackVirtualNic);
+            groupBox2.Controls.Add(label11);
+            groupBox2.Controls.Add(lblProcessLoopBackVirtualNic);
+            groupBox2.Controls.Add(label9);
+            groupBox2.Location = new Point(8, 6);
+            groupBox2.Name = "groupBox2";
+            groupBox2.Size = new Size(271, 70);
+            groupBox2.TabIndex = 2;
+            groupBox2.TabStop = false;
+            groupBox2.Text = "网络环境:这破玩意儿需要本机有一个IP地址";
+            // 
+            // btnProcessLoopBackVirtualNic
+            // 
+            btnProcessLoopBackVirtualNic.Location = new Point(6, 22);
+            btnProcessLoopBackVirtualNic.Name = "btnProcessLoopBackVirtualNic";
+            btnProcessLoopBackVirtualNic.Size = new Size(45, 45);
+            btnProcessLoopBackVirtualNic.TabIndex = 0;
+            btnProcessLoopBackVirtualNic.Text = "处理";
+            btnProcessLoopBackVirtualNic.UseVisualStyleBackColor = true;
+            btnProcessLoopBackVirtualNic.Click += btnProcessLoopBackVirtualNic_Click;
+            // 
+            // lblProcessLoopBackVirtualNic
+            // 
+            lblProcessLoopBackVirtualNic.AutoSize = true;
+            lblProcessLoopBackVirtualNic.Location = new Point(107, 44);
+            lblProcessLoopBackVirtualNic.Name = "lblProcessLoopBackVirtualNic";
+            lblProcessLoopBackVirtualNic.Size = new Size(44, 17);
+            lblProcessLoopBackVirtualNic.TabIndex = 3;
+            lblProcessLoopBackVirtualNic.Text = "待检测";
+            // 
             // groupBox11
             // 
             groupBox11.Controls.Add(btnAppDataOverwrite);
@@ -369,90 +527,6 @@
             btnAppDataOverwrite.UseVisualStyleBackColor = true;
             btnAppDataOverwrite.Click += btnAppDataOverwrite_Click;
             // 
-            // groupBox9
-            // 
-            groupBox9.Controls.Add(label14);
-            groupBox9.Controls.Add(cboAimeCard);
-            groupBox9.Controls.Add(btnAimeRefresh);
-            groupBox9.Controls.Add(btnAimeWrite);
-            groupBox9.Location = new Point(8, 6);
-            groupBox9.Name = "groupBox9";
-            groupBox9.Size = new Size(333, 100);
-            groupBox9.TabIndex = 9;
-            groupBox9.TabStop = false;
-            groupBox9.Text = "Aime卡";
-            // 
-            // label14
-            // 
-            label14.AutoSize = true;
-            label14.Location = new Point(8, 57);
-            label14.Name = "label14";
-            label14.Size = new Size(248, 34);
-            label14.TabIndex = 11;
-            label14.Text = "帮你写进aime.txt\r\n数据库启动后按刷新可以列出目前用过的卡号";
-            // 
-            // cboAimeCard
-            // 
-            cboAimeCard.FormattingEnabled = true;
-            cboAimeCard.Location = new Point(64, 22);
-            cboAimeCard.MaxLength = 24;
-            cboAimeCard.Name = "cboAimeCard";
-            cboAimeCard.Size = new Size(195, 25);
-            cboAimeCard.TabIndex = 10;
-            // 
-            // btnAimeRefresh
-            // 
-            btnAimeRefresh.Location = new Point(5, 22);
-            btnAimeRefresh.Name = "btnAimeRefresh";
-            btnAimeRefresh.Size = new Size(53, 23);
-            btnAimeRefresh.TabIndex = 2;
-            btnAimeRefresh.Text = "刷新";
-            btnAimeRefresh.UseVisualStyleBackColor = true;
-            btnAimeRefresh.Click += btnAimeRefresh_Click;
-            // 
-            // btnAimeWrite
-            // 
-            btnAimeWrite.Location = new Point(265, 22);
-            btnAimeWrite.Name = "btnAimeWrite";
-            btnAimeWrite.Size = new Size(37, 23);
-            btnAimeWrite.TabIndex = 2;
-            btnAimeWrite.Text = "写";
-            btnAimeWrite.UseVisualStyleBackColor = true;
-            btnAimeWrite.Click += btnAimeWrite_Click;
-            // 
-            // groupBox7
-            // 
-            groupBox7.Controls.Add(chkWinTrickAuto);
-            groupBox7.Controls.Add(btnWinTrick);
-            groupBox7.Location = new Point(6, 6);
-            groupBox7.Name = "groupBox7";
-            groupBox7.Size = new Size(263, 70);
-            groupBox7.TabIndex = 3;
-            groupBox7.TabStop = false;
-            groupBox7.Text = "窗口调整:启动之后窗口可能会乱跳";
-            // 
-            // chkWinTrickAuto
-            // 
-            chkWinTrickAuto.AutoSize = true;
-            chkWinTrickAuto.Checked = true;
-            chkWinTrickAuto.CheckState = CheckState.Checked;
-            chkWinTrickAuto.Location = new Point(76, 33);
-            chkWinTrickAuto.Name = "chkWinTrickAuto";
-            chkWinTrickAuto.Size = new Size(99, 21);
-            chkWinTrickAuto.TabIndex = 6;
-            chkWinTrickAuto.Text = "保持自动调整";
-            chkWinTrickAuto.UseVisualStyleBackColor = true;
-            // 
-            // btnWinTrick
-            // 
-            btnWinTrick.Location = new Point(6, 20);
-            btnWinTrick.Name = "btnWinTrick";
-            btnWinTrick.Size = new Size(64, 44);
-            btnWinTrick.TabIndex = 2;
-            btnWinTrick.Text = "调整";
-            btnWinTrick.UseVisualStyleBackColor = true;
-            btnWinTrick.Click += btnWinTrick_Click;
-            // 
             // groupBox3
             // 
             groupBox3.Controls.Add(lblPidMaria);
@@ -693,8 +767,8 @@
             // tcMain
             // 
             tcMain.Controls.Add(tpMainControl);
-            tcMain.Controls.Add(tpAimeCard);
-            tcMain.Controls.Add(tpUtils);
+            tcMain.Controls.Add(tpUtils1);
+            tcMain.Controls.Add(tpUtils2);
             tcMain.Controls.Add(tpMisc);
             tcMain.Controls.Add(tpSubControls);
             tcMain.Controls.Add(tpConsoles);
@@ -722,29 +796,6 @@
             tpMainControl.Text = "主控";
             tpMainControl.UseVisualStyleBackColor = true;
             // 
-            // tpAimeCard
-            // 
-            tpAimeCard.Controls.Add(groupBox9);
-            tpAimeCard.Location = new Point(4, 26);
-            tpAimeCard.Name = "tpAimeCard";
-            tpAimeCard.Padding = new Padding(3);
-            tpAimeCard.Size = new Size(716, 127);
-            tpAimeCard.TabIndex = 5;
-            tpAimeCard.Text = "Aime卡";
-            tpAimeCard.UseVisualStyleBackColor = true;
-            // 
-            // tpUtils
-            // 
-            tpUtils.Controls.Add(groupBox7);
-            tpUtils.Controls.Add(groupBox10);
-            tpUtils.Location = new Point(4, 26);
-            tpUtils.Name = "tpUtils";
-            tpUtils.Padding = new Padding(3);
-            tpUtils.Size = new Size(716, 127);
-            tpUtils.TabIndex = 1;
-            tpUtils.Text = "实用工具";
-            tpUtils.UseVisualStyleBackColor = true;
-            // 
             // tpMisc
             // 
             tpMisc.Controls.Add(groupBox2);
@@ -878,16 +929,19 @@
             FormClosing += MainForm_FormClosing;
             FormClosed += MainForm_FormClosed;
             Shown += MainForm_Shown;
-            groupBox2.ResumeLayout(false);
-            groupBox2.PerformLayout();
+            groupBox9.ResumeLayout(false);
+            tpUtils1.ResumeLayout(false);
+            groupBox1.ResumeLayout(false);
+            groupBox1.PerformLayout();
+            tpUtils2.ResumeLayout(false);
+            groupBox7.ResumeLayout(false);
+            groupBox7.PerformLayout();
             groupBox10.ResumeLayout(false);
             groupBox10.PerformLayout();
+            groupBox2.ResumeLayout(false);
+            groupBox2.PerformLayout();
             groupBox11.ResumeLayout(false);
             groupBox11.PerformLayout();
-            groupBox9.ResumeLayout(false);
-            groupBox9.PerformLayout();
-            groupBox7.ResumeLayout(false);
-            groupBox7.PerformLayout();
             groupBox3.ResumeLayout(false);
             groupBox3.PerformLayout();
             groupBox6.ResumeLayout(false);
@@ -899,8 +953,6 @@
             tcMain.ResumeLayout(false);
             tpMainControl.ResumeLayout(false);
             tpMainControl.PerformLayout();
-            tpAimeCard.ResumeLayout(false);
-            tpUtils.ResumeLayout(false);
             tpMisc.ResumeLayout(false);
             tpSubControls.ResumeLayout(false);
             tpConsoles.ResumeLayout(false);
@@ -930,7 +982,7 @@
         private Label lblMainControlStatus;
         private TabControl tcMain;
         private TabPage tpMainControl;
-        private TabPage tpUtils;
+        private TabPage tpUtils2;
         private TabPage tpMisc;
         private TabPage tpConsoles;
         private TabControl tcConsoles;
@@ -944,7 +996,7 @@
         private Button btnWinTrick;
         private Label lblProcessLoopBackVirtualNic;
         private TabPage tpSubControls;
-        private TabPage tpAimeCard;
+        private TabPage tpUtils1;
         private GroupBox groupBox9;
         private Button btnAimeWrite;
         private GroupBox groupBox3;
@@ -976,6 +1028,9 @@
         private Label lblPidInjector;
         private TabPage tpRecordScreen;
         private Button btnAimeRefresh;
-        private Label label14;
+        private Label label16;
+        private Button btnSysVolumeDec;
+        private Button btnSysVolumeInc;
+        private Label lblSysVolume;
     }
 }

+ 41 - 4
MainForm.cs

@@ -396,7 +396,8 @@ public partial class MainForm : Form
         mainControlStatusTextAnimation = false;
     }
 
-    private DateTime lastCheckWin = DateTime.Now;
+    private DateTime lastCheckSinMaiMainWinPos = DateTime.Now;
+    private DateTime lastCheckSysVolume = DateTime.Now;
 
     private void tmrMain_Tick(object sender, EventArgs e)
     {
@@ -411,9 +412,9 @@ public partial class MainForm : Form
         }
 
         //窗口调整
-        if (chkWinTrickAuto.Checked && lastCheckWin < DateTime.Now.AddSeconds(-5))
+        if (chkWinTrickAuto.Checked && lastCheckSinMaiMainWinPos < DateTime.Now.AddSeconds(-5))
         {
-            lastCheckWin = DateTime.Now;
+            lastCheckSinMaiMainWinPos = DateTime.Now;
 
             var pb = (ChildProcessStateBagForWin)childProcessControlGroups[ChildProcessKind.SinMai].StateBag;
 
@@ -422,6 +423,14 @@ public partial class MainForm : Form
                 MoveSinMaiMainWindow();
             }
         }
+
+        //显示系统音量
+        if (lastCheckSysVolume < DateTime.Now.AddSeconds(-1))
+        {
+            lastCheckSinMaiMainWinPos = DateTime.Now;
+            var sv = SystemAudioVolumeInterop.GetVolume();
+            lblSysVolume.Text = sv.HasValue ? $"{sv:N2}%" : "-";
+        }
     }
 
     private void btnAimeWrite_Click(object sender, EventArgs e)
@@ -450,7 +459,7 @@ public partial class MainForm : Form
 
         File.WriteAllText(setting.AimeFleSinMaiPath, aime);
 
-        MessageBox.Show($"已将选定的卡号已写入 aime.txt !{Environment.NewLine}在游戏登录时按回车键读卡{Environment.NewLine}(按一次回车不行就多按几次回车键)");
+        MessageBox.Show($"已将选定的卡号已写入 aime.txt !{Environment.NewLine}在游戏登录时按回车键读卡{Environment.NewLine}(按一次回车不行就多按几次回车键直到读卡成功🙄)");
     }
 
     private void btnWinTrick_Click(object sender, EventArgs e)
@@ -548,4 +557,32 @@ public partial class MainForm : Form
     {
         MessageBox.Show("还没做!");
     }
+
+    private void btnSysVolumeDec_Click(object sender, EventArgs e)
+    {
+        var sv = SystemAudioVolumeInterop.GetVolume();
+        if (!sv.HasValue)
+        {
+            MessageBox.Show("无法获取当前音量");
+            return;
+        }
+
+        sv -= 5;
+        if (sv < 0) sv = 0;
+        if (SystemAudioVolumeInterop.SetVolume(sv.Value) == false) MessageBox.Show("音量调整失败");
+    }
+
+    private void btnSysVolumeInc_Click(object sender, EventArgs e)
+    {
+        var sv = SystemAudioVolumeInterop.GetVolume();
+        if (!sv.HasValue)
+        {
+            MessageBox.Show("无法获取当前音量");
+            return;
+        }
+
+        sv += 5;
+        if (sv > 100) sv = 100;
+        if (SystemAudioVolumeInterop.SetVolume(sv.Value) == false) MessageBox.Show("音量调整失败");
+    }
 }

+ 12 - 0
MainForm.resx

@@ -162,6 +162,18 @@
   <metadata name="label13.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </metadata>
+  <metadata name="groupBox9.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="tpUtils1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+  <metadata name="tpUtils2.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
   <metadata name="tmrMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>

+ 1 - 0
SinMaiLauncher.csproj

@@ -12,6 +12,7 @@
 
 	<ItemGroup>
 		<PackageReference Include="MySql.Data" Version="9.2.0" />
+		<PackageReference Include="NAudio" Version="2.2.1" />
 	</ItemGroup>
 
 </Project>