diff --git a/src/MaaWpfGui/Main/SettingsViewModel.cs b/src/MaaWpfGui/Main/SettingsViewModel.cs index 4b8eddf614..4429711ef2 100644 --- a/src/MaaWpfGui/Main/SettingsViewModel.cs +++ b/src/MaaWpfGui/Main/SettingsViewModel.cs @@ -40,6 +40,14 @@ namespace MaaWpfGui [DllImport("MaaCore.dll")] private static extern IntPtr AsstGetVersion(); + [DllImport("user32.dll")] + private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + + private const int SWMINIMIZE = 6; + + [DllImport("user32.dll")] + private static extern bool IsIconic(IntPtr hWnd); + private static readonly string s_versionId = Marshal.PtrToStringAnsi(AsstGetVersion()); /// @@ -330,6 +338,18 @@ namespace MaaWpfGui } } + private bool _minimizingStartup = Convert.ToBoolean(ViewStatusStorage.Get("Start.MinimizingStartup", bool.FalseString)); + + public bool MinimizingStartup + { + get => _minimizingStartup; + set + { + SetAndNotify(ref _minimizingStartup, value); + ViewStatusStorage.Set("Start.MinimizingStartup", value.ToString()); + } + } + private string _emulatorPath = ViewStatusStorage.Get("Start.EmulatorPath", string.Empty); /// @@ -389,13 +409,30 @@ namespace MaaWpfGui return; } + ProcessStartInfo startInfo; if (EmulatorAddCommand.Length != 0) { - Process.Start(EmulatorPath, EmulatorAddCommand); + startInfo = new ProcessStartInfo(EmulatorPath, EmulatorAddCommand); } else { - Process.Start(EmulatorPath); + startInfo = new ProcessStartInfo(EmulatorPath); + } + + startInfo.UseShellExecute = false; + Process process = new Process + { + StartInfo = startInfo, + }; + + process.Start(); + process.WaitForInputIdle(); + if (MinimizingStartup) + { + while (!IsIconic(process.MainWindowHandle)) + { + ShowWindow(process.MainWindowHandle, SWMINIMIZE); + } } if (!int.TryParse(EmulatorWaitSeconds, out int delay)) diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index ca34e4ade4..78eb3a70d4 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -172,6 +172,7 @@ Auto Run task after launched Client Type Startup Emulator after launched + Minimizing the startup Emulator Delay time Emulator exec path Select diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 741bb09e2a..5a9cc10dce 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -139,6 +139,7 @@ アプリの起動時に自動的に実行 クライアントバージョン 起動時にエミュレータ自動起動 + エミュレーターの起動を最小化する エミュレータを待つ時間(秒) エミュレータパス 選択 diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 4b4fca1294..424a2ec3c0 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -171,6 +171,7 @@ 실행 후 작업 시작 클라이언트 종류 실행 후 에뮬레이터를 실행 + 시작 시뮬레이터 최소화 에뮬레이터 실행 대기 (초) 에뮬레이터 경로 선택 diff --git a/src/MaaWpfGui/Res/Localizations/pallas.xaml b/src/MaaWpfGui/Res/Localizations/pallas.xaml index 2f248bfd20..3c147b33f1 100644 --- a/src/MaaWpfGui/Res/Localizations/pallas.xaml +++ b/src/MaaWpfGui/Res/Localizations/pallas.xaml @@ -136,6 +136,7 @@ 🍻🍸🍸🍺🍷🍺🍻🍷 🍺🍷🍸🍸🍷🍻 💃💃🍻🍸🍺🍸🍺🍸🕺🍺🍸 + 🍷🍸🍸🍺🍷🍺🍻🍷 🍻💃🕺🍻🍷🍷🍷🍷🍸🕺🍺🍷🍸 🍻🍸🍸🍷🍻🕺 🍺🍻🍸 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 28f67748d3..0bae67a680 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -172,6 +172,7 @@ 启动后直接运行 客户端类型 启动后自动开启模拟器 + 最小化启动模拟器 等待模拟器启动时间(秒) 模拟器路径 选择 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 59d1f41754..272d68d04e 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -137,6 +137,7 @@ 啟動後直接運行 用戶端類型 啟動後自動開啟模擬器 + 最小化啟動模擬器 等待模擬器啟動時間(秒) 模擬器路徑 選擇 diff --git a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml index 262e1bd0af..545071ee02 100644 --- a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml @@ -110,7 +110,7 @@ - + Orientation="Vertical"> + + +