mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
Merge branch 'MaaAssistantArknights:dev' into dev
This commit is contained in:
@@ -210,7 +210,7 @@
|
||||
"位移"
|
||||
],
|
||||
[
|
||||
"Crowd Control",
|
||||
"Crowd-Control",
|
||||
"控场"
|
||||
],
|
||||
[
|
||||
|
||||
@@ -1557,9 +1557,9 @@
|
||||
"algorithm": "JustReturn",
|
||||
"action": "DoNothing",
|
||||
"next": [
|
||||
"UsePrts-Annihilation",
|
||||
"UsePrts",
|
||||
"UsePrts-StageSN",
|
||||
"UsePrts-Annihilation",
|
||||
"StartButton1",
|
||||
"PRTS3",
|
||||
"PRTS",
|
||||
@@ -1679,6 +1679,7 @@
|
||||
],
|
||||
"cache": false,
|
||||
"next": [
|
||||
"UsePrts-Annihilation",
|
||||
"StartButton1"
|
||||
]
|
||||
},
|
||||
@@ -2445,9 +2446,9 @@
|
||||
],
|
||||
"action": "ClickSelf",
|
||||
"next": [
|
||||
"UsePrts-Annihilation",
|
||||
"UsePrts",
|
||||
"UsePrts-StageSN",
|
||||
"UsePrts-Annihilation",
|
||||
"StartButton1"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace MeoAsstGui
|
||||
/// <remarks>初始化些啥自己加。</remarks>
|
||||
protected override void OnStart()
|
||||
{
|
||||
System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
|
||||
base.OnStart();
|
||||
ViewStatusStorage.Load();
|
||||
Localization.Load();
|
||||
|
||||
@@ -16,6 +16,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -958,6 +959,60 @@ namespace MeoAsstGui
|
||||
settings.RoguelikeSquad, settings.RoguelikeRoles, settings.RoguelikeCoreChar);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "FindWindow")]
|
||||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int GetWindowThreadProcessId(IntPtr hwnd, out int id);
|
||||
|
||||
/// <summary>
|
||||
/// Kills emulator by Window hwnd.
|
||||
/// </summary>
|
||||
/// <returns>Whether the operation is successful.</returns>
|
||||
public bool killEumlatorbyWindow()
|
||||
{
|
||||
IntPtr hwnd;
|
||||
int pid = 0;
|
||||
var windowname = new[] { "BlueStacks App Player", "BlueStacks", "明日方舟 - MuMu模拟器", "夜神模拟器", "逍遥模拟器", "明日方舟" };
|
||||
Process emulator;
|
||||
foreach (string i in windowname)
|
||||
{
|
||||
hwnd = FindWindow(null, i);
|
||||
if (hwnd != IntPtr.Zero)
|
||||
{
|
||||
GetWindowThreadProcessId(hwnd, out pid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pid != 0)
|
||||
{
|
||||
emulator = Process.GetProcessById(pid);
|
||||
emulator.CloseMainWindow();
|
||||
if (!emulator.HasExited)
|
||||
{
|
||||
try
|
||||
{
|
||||
emulator.Kill();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return killEmulator();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return killEmulator();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kills emulator.
|
||||
/// </summary>
|
||||
@@ -1104,7 +1159,7 @@ namespace MeoAsstGui
|
||||
break;
|
||||
|
||||
case ActionType.ExitEmulator:
|
||||
if (!killEmulator())
|
||||
if (!killEumlatorbyWindow())
|
||||
{
|
||||
AddLog(Localization.GetString("CloseEmulatorFailed"), "DarkRed");
|
||||
}
|
||||
@@ -1112,7 +1167,7 @@ namespace MeoAsstGui
|
||||
break;
|
||||
|
||||
case ActionType.ExitEmulatorAndSelf:
|
||||
if (!killEmulator())
|
||||
if (!killEumlatorbyWindow())
|
||||
{
|
||||
AddLog(Localization.GetString("CloseEmulatorFailed"), "DarkRed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user