fix: disable unsolicited background UI automation

This commit is contained in:
2026-09-20 18:40:23 +08:00
parent 7bf994de88
commit e17124de59
7 changed files with 56 additions and 17 deletions
+13 -6
View File
@@ -359,7 +359,7 @@ internal static class ServiceSettingsEditor
{
Text = "WxAgent 服务设置",
Width = 620,
Height = 405,
Height = 435,
StartPosition = FormStartPosition.CenterScreen,
MinimizeBox = false,
MaximizeBox = false,
@@ -385,18 +385,24 @@ internal static class ServiceSettingsEditor
Text = "防止自动息屏、睡眠和锁屏",
Checked = current.PreventAutoLock
};
var listenerEvents = new CheckBox
{
Left = 145, Top = 216, Width = 430,
Text = "启用后台消息监听(会操作微信界面,默认关闭)",
Checked = current.EnableListenerEvents
};
var note = new Label
{
Left = 18, Top = 220, Width = 570, Height = 48,
Left = 18, Top = 250, Width = 570, Height = 48,
Text = "仅保留一个访问凭据,可直接输入自定义内容(不能为空或包含空白字符)。\n验证写操作只应在明确授权的测试机启用;本机回环访问不需要凭据。"
};
var data = new Label
{
Left = 18, Top = 278, Width = 570, Height = 24,
Left = 18, Top = 308, Width = 570, Height = 24,
Text = $"数据目录:{current.DataDirectory}", AutoEllipsis = true
};
var save = new Button { Left = 370, Top = 330, Width = 105, Text = "保存" };
var cancel = new Button { Left = 485, Top = 330, Width = 105, Text = "取消" };
var save = new Button { Left = 370, Top = 360, Width = 105, Text = "保存" };
var cancel = new Button { Left = 485, Top = 360, Width = 105, Text = "取消" };
copy.Click += (_, _) => { Clipboard.SetText(tokenBox.Text); copy.Text = "已复制"; };
regenerate.Click += (_, _) =>
{
@@ -425,6 +431,7 @@ internal static class ServiceSettingsEditor
Reporting = current.Reporting,
RemoteConfigurationFile = current.RemoteConfigurationFile,
EnableValidationOperations = validation.Checked,
EnableListenerEvents = listenerEvents.Checked,
PreventAutoLock = preventAutoLock.Checked
};
try { edited.Validate(); }
@@ -437,7 +444,7 @@ internal static class ServiceSettingsEditor
form.Close();
};
cancel.Click += (_, _) => form.Close();
form.Controls.AddRange([listenLabel, hostBox, portBox, external, tokenLabel, tokenBox, copy, regenerate, validation, preventAutoLock, note, data, save, cancel]);
form.Controls.AddRange([listenLabel, hostBox, portBox, external, tokenLabel, tokenBox, copy, regenerate, validation, preventAutoLock, listenerEvents, note, data, save, cancel]);
form.AcceptButton = save;
form.CancelButton = cancel;
form.ShowDialog();