diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index e181d6b58e..3354abe7ec 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -2225,14 +2225,14 @@ namespace MaaWpfGui.ViewModels.UI
}
private readonly string _bluestacksConfig = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigPath, string.Empty);
- private readonly string _bluestacksKeyWord = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigKeyword, "bst.instance.Nougat64.status.adb_port");
+ private string _bluestacksKeyWord = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigKeyword, string.Empty);
///
/// Tries to set Bluestack Hyper V address.
///
public void TryToSetBlueStacksHyperVAddress()
{
- if (_bluestacksConfig.Length == 0)
+ if (String.IsNullOrEmpty(_bluestacksConfig))
{
return;
}
@@ -2244,12 +2244,27 @@ namespace MaaWpfGui.ViewModels.UI
}
var all_lines = File.ReadAllLines(_bluestacksConfig);
+
+ if (String.IsNullOrEmpty(_bluestacksKeyWord))
+ {
+ foreach (var line in all_lines)
+ {
+ if (line.StartsWith("bst.installed_images"))
+ {
+ var images = line.Split('"')[1].Split(',');
+ _bluestacksKeyWord = "bst.instance." + images[0] + ".status.adb_port";
+ break;
+ }
+ }
+ }
+
foreach (var line in all_lines)
{
if (line.StartsWith(_bluestacksKeyWord))
{
var sp = line.Split('"');
ConnectAddress = "127.0.0.1:" + sp[1];
+ break;
}
}
}
diff --git a/src/Python/asst/emulator.py b/src/Python/asst/emulator.py
index 64df006e30..1416406934 100644
--- a/src/Python/asst/emulator.py
+++ b/src/Python/asst/emulator.py
@@ -3,15 +3,18 @@ import subprocess
class Bluestacks:
@staticmethod
- def get_hyperv_port(conf_path=r"C:\ProgramData\BlueStacks_nxt\bluestacks.conf", instance_name="Pie64") -> int:
+ def get_hyperv_port(conf_path=r"C:\ProgramData\BlueStacks_nxt\bluestacks.conf", instance_name="Pie64", read_imageinfo_from_config=False) -> int:
""" 获取Hyper-v版蓝叠的adb port
:param conf_path: bluestacks.conf 的路径+文件名
:param instance_name: 多开的名称,在bluestacks.conf中以类似bst.instance..status.adb_port的形式出现,如Nougat64,Pie64,Pie64_1等
:return: adb端口
"""
- with open(conf_path) as f:
+ with open(conf_path, encoding="UTF-8") as f:
configs = dict(list(map(lambda line: line.replace('\n', '').split('='), f.readlines())))
+ if read_imageinfo_from_config:
+ instances = [i.strip('"') for i in configs['bst.installed_images'].split(',')]
+ instance_name = instances[0]
return int(configs[f'bst.instance.{instance_name}.status.adb_port'].replace('"', ""))
@staticmethod