Merge branch 'main' into main

This commit is contained in:
辉鸭蛋 2024-08-20 01:15:55 +08:00 committed by GitHub
commit 64c5ab78bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 4886 additions and 59 deletions

View File

@ -5,7 +5,7 @@ namespace BetterGenshinImpact.Core.Config;
public class Global
{
public static string Version { get; } = "0.32.6";
public static string Version { get; } = "0.33.1";
public static string StartUpPath { get; set; } = AppContext.BaseDirectory;

View File

@ -1,8 +1,13 @@
using BetterGenshinImpact.Core.Script.Project;
using BetterGenshinImpact.Core.Recorder;
using BetterGenshinImpact.Core.Script.Dependence;
using BetterGenshinImpact.Core.Script.Project;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using BetterGenshinImpact.Core.Config;
namespace BetterGenshinImpact.Core.Script.Group;
@ -18,6 +23,9 @@ public partial class ScriptGroupProject : ObservableObject
[ObservableProperty]
private string _type = string.Empty;
[JsonIgnore]
public string TypeDesc => ScriptGroupProjectExtensions.TypeDescriptions[Type];
[ObservableProperty]
private string _status = string.Empty;
@ -35,7 +43,7 @@ public partial class ScriptGroupProject : ObservableObject
public string ScheduleDesc => ScriptGroupProjectExtensions.ScheduleDescriptions.GetValueOrDefault(Schedule, "自定义周期");
[ObservableProperty]
private string _runNum = string.Empty;
private int _runNum = 1;
[JsonIgnore]
public ScriptProject? Project { get; set; }
@ -51,6 +59,17 @@ public partial class ScriptGroupProject : ObservableObject
Status = "Enabled";
Schedule = "Daily";
Project = project;
Type = "Javascript";
}
public ScriptGroupProject(string kmName)
{
Name = kmName;
FolderName = kmName;
Status = "Enabled";
Schedule = "Daily";
Project = null; // 不是Js脚本
Type = "KeyMouse";
}
/// <summary>
@ -64,16 +83,64 @@ public partial class ScriptGroupProject : ObservableObject
}
Project = new ScriptProject(FolderName);
}
public async Task Run()
{
if (Type == "Javascript")
{
if (Project == null)
{
throw new Exception("JS脚本未初始化");
}
await Project.ExecuteAsync();
}
if (Type == "KeyMouse")
{
// 加载并执行
var json = await File.ReadAllTextAsync(Global.Absolute(@$"User\KeyMouseScript\{Name}"));
await KeyMouseMacroPlayer.PlayMacro(json, CancellationContext.Instance.Cts.Token, false);
}
else
{
throw new Exception("不支持的脚本类型");
}
}
partial void OnTypeChanged(string value)
{
OnPropertyChanged(nameof(TypeDesc));
}
partial void OnStatusChanged(string value)
{
OnPropertyChanged(nameof(StatusDesc));
}
partial void OnScheduleChanged(string value)
{
OnPropertyChanged(nameof(ScheduleDesc));
}
}
public static class ScriptGroupProjectExtensions
public class ScriptGroupProjectExtensions
{
public static readonly Dictionary<string, string> TypeDescriptions = new()
{
{ "Javascript", "JS脚本" },
{ "KeyMouse", "键鼠脚本" }
};
public static readonly Dictionary<string, string> StatusDescriptions = new()
{
{ "Enabled", "启用" },
{ "Disabled", "禁用" }
};
public Dictionary<string, string> GetStatusDescriptions()
{
return StatusDescriptions;
}
public static readonly Dictionary<string, string> ScheduleDescriptions = new()
{
{ "Daily", "每日" },
@ -86,4 +153,9 @@ public static class ScriptGroupProjectExtensions
{ "Saturday", "每周六" },
{ "Sunday", "每周日" }
};
public Dictionary<string, string> GetScheduleDescriptions()
{
return ScheduleDescriptions;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1,494 @@
{"macroEvents":[{"type":3,"mouseX":-7,"mouseY":1,"time":576.0821},{"type":3,"mouseX":-9,"mouseY":1,"time":603.2379},{"type":3,"mouseX":-13,"mouseY":2,"time":625.2123},{"type":3,"mouseX":-21,"mouseY":4,"time":647.0952},{"type":3,"mouseX":-16,"mouseY":4,"time":669.8491},{"type":3,"mouseX":-10,"mouseY":2,"time":697.1075},{"type":3,"mouseX":-11,"mouseY":2,"time":725.0925},{"type":3,"mouseX":-20,"mouseY":3,"time":747.324},{"type":3,"mouseX":-15,"mouseY":3,"time":770.6291},{"type":3,"mouseX":-9,"mouseY":1,"time":798.0281},{"type":3,"mouseX":-1,"mouseY":0,"time":832.5139},{"type":0,"keyCode":83,"mouseX":0,"mouseY":0,"time":1205.3665},{"type":3,"mouseX":-1,"mouseY":0,"time":1266.6846},{"type":3,"mouseX":-4,"mouseY":0,"time":1305.4125},{"type":3,"mouseX":-2,"mouseY":0,"time":1326.8556},{"type":4,"mouseX":1280,"mouseY":719,"mouseButton":"Right","time":1337.8531},{"type":3,"mouseX":-1,"mouseY":0,"time":1338.0364},{"type":3,"mouseX":-2,"mouseY":0,"time":1479.7232},{"type":3,"mouseX":-4,"mouseY":1,"time":1501.6012},{"type":3,"mouseX":-6,"mouseY":2,"time":1569.6545},{"type":3,"mouseX":-1,"mouseY":0,"time":1609.0565},{"type":3,"mouseX":-3,"mouseY":-1,"time":1648.3312},{"type":5,"mouseX":1280,"mouseY":718,"mouseButton":"Right","time":1659.0017},{"type":3,"mouseX":-2,"mouseY":-1,"time":1665.3868},{"type":3,"mouseX":-6,"mouseY":-3,"time":1693.0753},{"type":3,"mouseX":-3,"mouseY":-2,"time":1716.7381},{"type":3,"mouseX":-1,"mouseY":-1,"time":1788.6268},{"type":1,"keyCode":83,"mouseX":0,"mouseY":0,"time":2286.2359},{"type":4,"mouseX":1280,"mouseY":718,"mouseButton":"Right","time":2479.4654},{"type":0,"keyCode":83,"mouseX":0,"mouseY":0,"time":2507.603},{"type":5,"mouseX":1280,"mouseY":718,"mouseButton":"Right","time":2599.3498},{"type":3,"mouseX":0,"mouseY":1,"time":2614.2672},{"type":3,"mouseX":1,"mouseY":0,"time":2653.0149},{"type":1,"keyCode":83,"mouseX":0,"mouseY":0,"time":2858.2602}],"info":{"name":"","description":"","x":319,"y":192,"width":1920,"height":1080}}
{
"macroEvents": [
{
"type": 3,
"mouseX": -2,
"mouseY": 0,
"time": 756.6828
},
{
"type": 3,
"mouseX": -19,
"mouseY": 0,
"time": 779.6848
},
{
"type": 3,
"mouseX": -24,
"mouseY": -1,
"time": 802.0181
},
{
"type": 3,
"mouseX": -23,
"mouseY": 0,
"time": 829.6695
},
{
"type": 3,
"mouseX": -19,
"mouseY": 1,
"time": 852.7538
},
{
"type": 3,
"mouseX": -15,
"mouseY": 0,
"time": 874.8491
},
{
"type": 3,
"mouseX": -8,
"mouseY": 0,
"time": 902.8351
},
{
"type": 3,
"mouseX": -7,
"mouseY": 0,
"time": 941.9856
},
{
"type": 3,
"mouseX": -13,
"mouseY": -1,
"time": 971.3797
},
{
"type": 3,
"mouseX": -13,
"mouseY": -2,
"time": 993.476
},
{
"type": 3,
"mouseX": -26,
"mouseY": -6,
"time": 1015.5798
},
{
"type": 3,
"mouseX": -60,
"mouseY": -6,
"time": 1038.5879
},
{
"type": 3,
"mouseX": -41,
"mouseY": 3,
"time": 1061.4093
},
{
"type": 3,
"mouseX": 3,
"mouseY": 0,
"time": 1245.2301
},
{
"type": 3,
"mouseX": 7,
"mouseY": 1,
"time": 1267.7227
},
{
"type": 3,
"mouseX": 1,
"mouseY": 0,
"time": 1295.128
},
{
"type": 0,
"keyCode": 83,
"mouseX": 0,
"mouseY": 0,
"time": 1353.9764
},
{
"type": 3,
"mouseX": 7,
"mouseY": 0,
"time": 1435.2147
},
{
"type": 3,
"mouseX": 2,
"mouseY": 0,
"time": 1456.9268
},
{
"type": 4,
"mouseX": 1280,
"mouseY": 718,
"mouseButton": "Right",
"time": 1501.3612
},
{
"type": 3,
"mouseX": 3,
"mouseY": 0,
"time": 1501.5163
},
{
"type": 3,
"mouseX": 4,
"mouseY": 2,
"time": 1535.0385
},
{
"type": 3,
"mouseX": 1,
"mouseY": 0,
"time": 1646.4199
},
{
"type": 5,
"mouseX": 1279,
"mouseY": 718,
"mouseButton": "Right",
"time": 1687.8808
},
{
"type": 3,
"mouseX": 2,
"mouseY": 0,
"time": 1734.9428
},
{
"type": 3,
"mouseX": 0,
"mouseY": 1,
"time": 1761.9969
},
{
"type": 3,
"mouseX": 0,
"mouseY": 1,
"time": 2320.3248
},
{
"type": 0,
"keyCode": 68,
"mouseX": 0,
"mouseY": 0,
"time": 2332.7129
},
{
"type": 3,
"mouseX": 1,
"mouseY": 0,
"time": 2332.7797
},
{
"type": 4,
"mouseX": 1279,
"mouseY": 718,
"mouseButton": "Right",
"time": 2469.8918
},
{
"type": 3,
"mouseX": -1,
"mouseY": 9,
"time": 2480.0733
},
{
"type": 3,
"mouseX": 0,
"mouseY": 2,
"time": 2502.6682
},
{
"type": 1,
"keyCode": 83,
"mouseX": 0,
"mouseY": 0,
"time": 2540.7554
},
{
"type": 3,
"mouseX": 0,
"mouseY": 1,
"time": 2562.9471
},
{
"type": 3,
"mouseX": 0,
"mouseY": 1,
"time": 2586.4817
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 2643.5947
},
{
"type": 0,
"keyCode": 87,
"mouseX": 0,
"mouseY": 0,
"time": 2666.7409
},
{
"type": 5,
"mouseX": 1280,
"mouseY": 718,
"mouseButton": "Right",
"time": 2675.9272
},
{
"type": 3,
"mouseX": -2,
"mouseY": -2,
"time": 2680.9534
},
{
"type": 3,
"mouseX": -4,
"mouseY": -9,
"time": 2702.9013
},
{
"type": 3,
"mouseX": -3,
"mouseY": -15,
"time": 2725.2434
},
{
"type": 3,
"mouseX": 0,
"mouseY": -16,
"time": 2753.2387
},
{
"type": 3,
"mouseX": 3,
"mouseY": -5,
"time": 2775.323
},
{
"type": 3,
"mouseX": 0,
"mouseY": -2,
"time": 2797.3051
},
{
"type": 1,
"keyCode": 68,
"mouseX": 0,
"mouseY": 0,
"time": 2801.8392
},
{
"type": 3,
"mouseX": -5,
"mouseY": -3,
"time": 2813.8055
},
{
"type": 3,
"mouseX": -6,
"mouseY": 0,
"time": 2836.0958
},
{
"type": 3,
"mouseX": -5,
"mouseY": 3,
"time": 2880.7288
},
{
"type": 3,
"mouseX": -11,
"mouseY": 6,
"time": 2902.1275
},
{
"type": 0,
"keyCode": 65,
"mouseX": 0,
"mouseY": 0,
"time": 2911.7599
},
{
"type": 3,
"mouseX": -12,
"mouseY": 7,
"time": 2912.8727
},
{
"type": 3,
"mouseX": -10,
"mouseY": 8,
"time": 2935.4167
},
{
"type": 3,
"mouseX": -6,
"mouseY": 10,
"time": 2957.0201
},
{
"type": 3,
"mouseX": -9,
"mouseY": 15,
"time": 2979.1435
},
{
"type": 3,
"mouseX": -10,
"mouseY": 18,
"time": 3002.9336
},
{
"type": 3,
"mouseX": -8,
"mouseY": 17,
"time": 3030.513
},
{
"type": 3,
"mouseX": -8,
"mouseY": 14,
"time": 3051.8262
},
{
"type": 3,
"mouseX": -4,
"mouseY": 13,
"time": 3073.8023
},
{
"type": 4,
"mouseX": 1279,
"mouseY": 718,
"mouseButton": "Right",
"time": 3099.89
},
{
"type": 3,
"mouseX": -4,
"mouseY": 22,
"time": 3100.8116
},
{
"type": 3,
"mouseX": -1,
"mouseY": 22,
"time": 3122.8164
},
{
"type": 3,
"mouseX": -1,
"mouseY": 4,
"time": 3145.2072
},
{
"type": 1,
"keyCode": 65,
"mouseX": 0,
"mouseY": 0,
"time": 3190.7386
},
{
"type": 3,
"mouseX": -3,
"mouseY": 11,
"time": 3207.8583
},
{
"type": 3,
"mouseX": 8,
"mouseY": 18,
"time": 3229.7503
},
{
"type": 3,
"mouseX": 15,
"mouseY": 3,
"time": 3252.2004
},
{
"type": 5,
"mouseX": 1279,
"mouseY": 719,
"mouseButton": "Right",
"time": 3269.8735
},
{
"type": 3,
"mouseX": 2,
"mouseY": -1,
"time": 3273.9592
},
{
"type": 3,
"mouseX": 3,
"mouseY": -2,
"time": 3295.961
},
{
"type": 3,
"mouseX": 1,
"mouseY": 0,
"time": 3335.1143
},
{
"type": 3,
"mouseX": 6,
"mouseY": -2,
"time": 3358.5404
},
{
"type": 3,
"mouseX": 15,
"mouseY": -5,
"time": 3381.0686
},
{
"type": 3,
"mouseX": 4,
"mouseY": -1,
"time": 3403.2515
},
{
"type": 3,
"mouseX": 1,
"mouseY": -1,
"time": 3470.4059
},
{
"type": 3,
"mouseX": 0,
"mouseY": 2,
"time": 3501.9418
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 3570.265
},
{
"type": 3,
"mouseX": 0,
"mouseY": 1,
"time": 3671.7778
},
{
"type": 1,
"keyCode": 87,
"mouseX": 0,
"mouseY": 0,
"time": 3858.7537
}
],
"info": {
"name": "",
"description": "",
"x": 319,
"y": 192,
"width": 1920,
"height": 1080
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1,824 @@
{"macroEvents":[{"type":3,"mouseX":-6,"mouseY":2,"time":1195.0968},{"type":3,"mouseX":-26,"mouseY":3,"time":1217.2596},{"type":3,"mouseX":-60,"mouseY":3,"time":1240.1011},{"type":3,"mouseX":-81,"mouseY":0,"time":1263.9769},{"type":3,"mouseX":-72,"mouseY":-2,"time":1286.2133},{"type":3,"mouseX":-58,"mouseY":-2,"time":1314.4205},{"type":3,"mouseX":-58,"mouseY":-4,"time":1337.4462},{"type":3,"mouseX":-70,"mouseY":-1,"time":1359.6639},{"type":3,"mouseX":-65,"mouseY":-1,"time":1381.9883},{"type":3,"mouseX":-51,"mouseY":-2,"time":1409.7675},{"type":3,"mouseX":-55,"mouseY":-3,"time":1433.0407},{"type":3,"mouseX":-64,"mouseY":-4,"time":1455.636},{"type":3,"mouseX":-77,"mouseY":-3,"time":1477.7445},{"type":3,"mouseX":-88,"mouseY":-2,"time":1504.5594},{"type":3,"mouseX":-70,"mouseY":-1,"time":1527.1848},{"type":3,"mouseX":-56,"mouseY":-1,"time":1548.8243},{"type":3,"mouseX":-64,"mouseY":0,"time":1576.974},{"type":3,"mouseX":-50,"mouseY":0,"time":1599.1094},{"type":3,"mouseX":-26,"mouseY":0,"time":1622.7203},{"type":3,"mouseX":-23,"mouseY":-2,"time":1649.1755},{"type":3,"mouseX":-22,"mouseY":0,"time":1671.8938},{"type":3,"mouseX":-19,"mouseY":-1,"time":1693.3202},{"type":3,"mouseX":-19,"mouseY":-1,"time":1721.004},{"type":3,"mouseX":-24,"mouseY":-2,"time":1741.7403},{"type":3,"mouseX":-15,"mouseY":-3,"time":1768.5004},{"type":3,"mouseX":16,"mouseY":2,"time":1939.8262},{"type":3,"mouseX":37,"mouseY":4,"time":1962.698},{"type":3,"mouseX":35,"mouseY":2,"time":1985.7569},{"type":3,"mouseX":18,"mouseY":2,"time":2012.7959},{"type":0,"keyCode":87,"mouseX":0,"mouseY":0,"time":2018.8509},{"type":3,"mouseX":37,"mouseY":3,"time":2024.1485},{"type":3,"mouseX":14,"mouseY":1,"time":2051.9759},{"type":3,"mouseX":3,"mouseY":0,"time":2107.3918},{"type":3,"mouseX":27,"mouseY":-4,"time":2129.8156},{"type":3,"mouseX":7,"mouseY":-2,"time":2151.6604},{"type":3,"mouseX":-3,"mouseY":-1,"time":2298.1665},{"type":3,"mouseX":-1,"mouseY":0,"time":2375.8263},{"type":3,"mouseX":0,"mouseY":1,"time":2481.0541},{"type":3,"mouseX":0,"mouseY":1,"time":2508.9174},{"type":3,"mouseX":0,"mouseY":1,"time":2597.6013},{"type":3,"mouseX":-2,"mouseY":1,"time":2635.7856},{"type":3,"mouseX":-1,"mouseY":2,"time":2763.9109},{"type":3,"mouseX":0,"mouseY":3,"time":2797.1696},{"type":3,"mouseX":-1,"mouseY":2,"time":2818.8425},{"type":3,"mouseX":-2,"mouseY":1,"time":2841.4413},{"type":3,"mouseX":0,"mouseY":2,"time":2870.2478},{"type":1,"keyCode":87,"mouseX":0,"mouseY":0,"time":2918.7259},{"type":3,"mouseX":0,"mouseY":1,"time":2981.7594},{"type":3,"mouseX":-1,"mouseY":1,"time":3047.5891},{"type":3,"mouseX":0,"mouseY":2,"time":3327.7434},{"type":3,"mouseX":-1,"mouseY":0,"time":3951.9777}],"info":{"name":"","description":"","x":319,"y":192,"width":1920,"height":1080}}
{
"macroEvents": [
{
"type": 3,
"mouseX": 0,
"mouseY": -1,
"time": 368.9396
},
{
"type": 3,
"mouseX": -11,
"mouseY": 1,
"time": 412.7782
},
{
"type": 3,
"mouseX": -25,
"mouseY": 2,
"time": 435.5507
},
{
"type": 3,
"mouseX": -37,
"mouseY": 1,
"time": 463.1231
},
{
"type": 3,
"mouseX": -30,
"mouseY": 4,
"time": 485.5294
},
{
"type": 3,
"mouseX": -19,
"mouseY": 0,
"time": 513.3165
},
{
"type": 3,
"mouseX": -60,
"mouseY": 1,
"time": 535.1435
},
{
"type": 3,
"mouseX": -161,
"mouseY": -1,
"time": 563.519
},
{
"type": 3,
"mouseX": -189,
"mouseY": -9,
"time": 591.3807
},
{
"type": 3,
"mouseX": -105,
"mouseY": -3,
"time": 615.1774
},
{
"type": 3,
"mouseX": -96,
"mouseY": -7,
"time": 638.11
},
{
"type": 3,
"mouseX": -89,
"mouseY": -9,
"time": 665.7458
},
{
"type": 3,
"mouseX": -50,
"mouseY": -1,
"time": 693.9088
},
{
"type": 3,
"mouseX": -13,
"mouseY": -2,
"time": 715.4002
},
{
"type": 3,
"mouseX": 0,
"mouseY": -1,
"time": 737.5235
},
{
"type": 3,
"mouseX": -3,
"mouseY": -1,
"time": 789.0101
},
{
"type": 3,
"mouseX": -6,
"mouseY": -3,
"time": 811.0222
},
{
"type": 3,
"mouseX": -9,
"mouseY": -4,
"time": 833.0476
},
{
"type": 3,
"mouseX": -11,
"mouseY": -3,
"time": 856.3616
},
{
"type": 0,
"keyCode": 87,
"mouseX": 0,
"mouseY": 0,
"time": 918.6658
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 940.9969
},
{
"type": 3,
"mouseX": -10,
"mouseY": -1,
"time": 1155.0089
},
{
"type": 3,
"mouseX": -29,
"mouseY": -2,
"time": 1178.4345
},
{
"type": 3,
"mouseX": -49,
"mouseY": -1,
"time": 1206.2128
},
{
"type": 3,
"mouseX": -59,
"mouseY": -4,
"time": 1228.5074
},
{
"type": 3,
"mouseX": -68,
"mouseY": -6,
"time": 1250.429
},
{
"type": 3,
"mouseX": -57,
"mouseY": -1,
"time": 1278.5902
},
{
"type": 3,
"mouseX": -24,
"mouseY": 0,
"time": 1300.7184
},
{
"type": 3,
"mouseX": 2,
"mouseY": -1,
"time": 1388.7203
},
{
"type": 3,
"mouseX": 6,
"mouseY": -1,
"time": 1411.8747
},
{
"type": 3,
"mouseX": 11,
"mouseY": 0,
"time": 1433.9314
},
{
"type": 3,
"mouseX": 21,
"mouseY": 1,
"time": 1456.5045
},
{
"type": 3,
"mouseX": 37,
"mouseY": 2,
"time": 1483.3014
},
{
"type": 3,
"mouseX": 60,
"mouseY": 5,
"time": 1506.0698
},
{
"type": 3,
"mouseX": 61,
"mouseY": 3,
"time": 1528.8274
},
{
"type": 3,
"mouseX": 42,
"mouseY": 2,
"time": 1555.5381
},
{
"type": 3,
"mouseX": 27,
"mouseY": 5,
"time": 1577.449
},
{
"type": 3,
"mouseX": 36,
"mouseY": 7,
"time": 1605.4825
},
{
"type": 3,
"mouseX": 68,
"mouseY": 8,
"time": 1629.4201
},
{
"type": 3,
"mouseX": 76,
"mouseY": 8,
"time": 1651.3134
},
{
"type": 3,
"mouseX": 65,
"mouseY": 7,
"time": 1672.9869
},
{
"type": 3,
"mouseX": 55,
"mouseY": 6,
"time": 1696.2064
},
{
"type": 3,
"mouseX": 65,
"mouseY": 8,
"time": 1724.1475
},
{
"type": 3,
"mouseX": 53,
"mouseY": 11,
"time": 1746.5202
},
{
"type": 3,
"mouseX": 39,
"mouseY": 9,
"time": 1768.8863
},
{
"type": 3,
"mouseX": 24,
"mouseY": 4,
"time": 1796.9861
},
{
"type": 3,
"mouseX": 15,
"mouseY": 6,
"time": 1819.1718
},
{
"type": 3,
"mouseX": 32,
"mouseY": 11,
"time": 1841.7927
},
{
"type": 4,
"mouseX": 1279,
"mouseY": 719,
"mouseButton": "Right",
"time": 1862.2272
},
{
"type": 3,
"mouseX": 51,
"mouseY": 16,
"time": 1865.0115
},
{
"type": 3,
"mouseX": 79,
"mouseY": 42,
"time": 1887.7571
},
{
"type": 3,
"mouseX": 104,
"mouseY": 86,
"time": 1910.7166
},
{
"type": 3,
"mouseX": 92,
"mouseY": 88,
"time": 1933.0649
},
{
"type": 3,
"mouseX": 44,
"mouseY": 46,
"time": 1956.23
},
{
"type": 0,
"keyCode": 32,
"mouseX": 0,
"mouseY": 0,
"time": 1970.1122
},
{
"type": 3,
"mouseX": 51,
"mouseY": 65,
"time": 1972.5315
},
{
"type": 3,
"mouseX": 41,
"mouseY": 80,
"time": 2000.6007
},
{
"type": 3,
"mouseX": 41,
"mouseY": 81,
"time": 2023.1234
},
{
"type": 3,
"mouseX": 43,
"mouseY": 55,
"time": 2044.7806
},
{
"type": 3,
"mouseX": 13,
"mouseY": 8,
"time": 2067.9549
},
{
"type": 5,
"mouseX": 1279,
"mouseY": 719,
"mouseButton": "Right",
"time": 2076.6793
},
{
"type": 3,
"mouseX": 29,
"mouseY": 11,
"time": 2079.4763
},
{
"type": 3,
"mouseX": 8,
"mouseY": 9,
"time": 2101.7817
},
{
"type": 3,
"mouseX": 11,
"mouseY": 14,
"time": 2130.2136
},
{
"type": 3,
"mouseX": 6,
"mouseY": 6,
"time": 2153.7804
},
{
"type": 1,
"keyCode": 32,
"mouseX": 0,
"mouseY": 0,
"time": 2155.7151
},
{
"type": 3,
"mouseX": 30,
"mouseY": 16,
"time": 2159.7059
},
{
"type": 3,
"mouseX": 37,
"mouseY": 27,
"time": 2183.3064
},
{
"type": 3,
"mouseX": 15,
"mouseY": 30,
"time": 2205.4419
},
{
"type": 3,
"mouseX": 0,
"mouseY": 17,
"time": 2233.9445
},
{
"type": 3,
"mouseX": 3,
"mouseY": 12,
"time": 2255.6281
},
{
"type": 3,
"mouseX": 9,
"mouseY": 13,
"time": 2277.4925
},
{
"type": 3,
"mouseX": 17,
"mouseY": 12,
"time": 2306.3558
},
{
"type": 3,
"mouseX": 19,
"mouseY": 14,
"time": 2335.1673
},
{
"type": 3,
"mouseX": 13,
"mouseY": 16,
"time": 2357.1774
},
{
"type": 3,
"mouseX": 19,
"mouseY": 16,
"time": 2384.5571
},
{
"type": 3,
"mouseX": 49,
"mouseY": 15,
"time": 2406.1211
},
{
"type": 3,
"mouseX": 86,
"mouseY": 12,
"time": 2429.1322
},
{
"type": 3,
"mouseX": 81,
"mouseY": 1,
"time": 2455.8043
},
{
"type": 3,
"mouseX": 65,
"mouseY": -4,
"time": 2477.4238
},
{
"type": 3,
"mouseX": 47,
"mouseY": 17,
"time": 2500.6422
},
{
"type": 3,
"mouseX": 29,
"mouseY": 16,
"time": 2527.9262
},
{
"type": 4,
"mouseX": 1279,
"mouseY": 718,
"mouseButton": "Right",
"time": 2542.1599
},
{
"type": 3,
"mouseX": 62,
"mouseY": 13,
"time": 2544.0434
},
{
"type": 3,
"mouseX": 31,
"mouseY": 0,
"time": 2572.2807
},
{
"type": 3,
"mouseX": 4,
"mouseY": 2,
"time": 2600.87
},
{
"type": 3,
"mouseX": 1,
"mouseY": 2,
"time": 2622.6591
},
{
"type": 3,
"mouseX": 1,
"mouseY": 0,
"time": 2651.7399
},
{
"type": 3,
"mouseX": 15,
"mouseY": 1,
"time": 2690.2704
},
{
"type": 3,
"mouseX": 11,
"mouseY": -1,
"time": 2712.4232
},
{
"type": 3,
"mouseX": 3,
"mouseY": -1,
"time": 2734.9242
},
{
"type": 5,
"mouseX": 1279,
"mouseY": 719,
"mouseButton": "Right",
"time": 2768.2118
},
{
"type": 3,
"mouseX": 10,
"mouseY": 3,
"time": 2768.6113
},
{
"type": 3,
"mouseX": 29,
"mouseY": 7,
"time": 2791.9305
},
{
"type": 3,
"mouseX": 31,
"mouseY": 1,
"time": 2814.1551
},
{
"type": 3,
"mouseX": 27,
"mouseY": 0,
"time": 2837.3218
},
{
"type": 3,
"mouseX": 15,
"mouseY": -2,
"time": 2864.1538
},
{
"type": 3,
"mouseX": 17,
"mouseY": -3,
"time": 2886.2924
},
{
"type": 3,
"mouseX": 5,
"mouseY": 0,
"time": 2914.3027
},
{
"type": 0,
"keyCode": 32,
"mouseX": 0,
"mouseY": 0,
"time": 2931.0862
},
{
"type": 4,
"mouseX": 1279,
"mouseY": 718,
"mouseButton": "Right",
"time": 2987.4492
},
{
"type": 3,
"mouseX": 0,
"mouseY": 2,
"time": 3001.3708
},
{
"type": 3,
"mouseX": -9,
"mouseY": 17,
"time": 3023.3102
},
{
"type": 3,
"mouseX": -2,
"mouseY": 3,
"time": 3052.0118
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 3074.4789
},
{
"type": 5,
"mouseX": 1280,
"mouseY": 718,
"mouseButton": "Right",
"time": 3086.2413
},
{
"type": 3,
"mouseX": 16,
"mouseY": -12,
"time": 3086.4157
},
{
"type": 3,
"mouseX": 40,
"mouseY": -16,
"time": 3114.6279
},
{
"type": 1,
"keyCode": 32,
"mouseX": 0,
"mouseY": 0,
"time": 3137.0662
},
{
"type": 3,
"mouseX": 21,
"mouseY": -11,
"time": 3138.732
},
{
"type": 3,
"mouseX": 0,
"mouseY": -7,
"time": 3160.8642
},
{
"type": 3,
"mouseX": 0,
"mouseY": -8,
"time": 3182.5505
},
{
"type": 3,
"mouseX": 9,
"mouseY": -1,
"time": 3223.1767
},
{
"type": 3,
"mouseX": 57,
"mouseY": 1,
"time": 3245.3632
},
{
"type": 3,
"mouseX": 58,
"mouseY": -2,
"time": 3267.7251
},
{
"type": 3,
"mouseX": 32,
"mouseY": -1,
"time": 3289.4374
},
{
"type": 3,
"mouseX": 40,
"mouseY": 3,
"time": 3311.6014
},
{
"type": 0,
"keyCode": 68,
"mouseX": 0,
"mouseY": 0,
"time": 3330.0833
},
{
"type": 3,
"mouseX": 65,
"mouseY": -2,
"time": 3334.6961
},
{
"type": 3,
"mouseX": 81,
"mouseY": -13,
"time": 3356.5099
},
{
"type": 3,
"mouseX": 92,
"mouseY": -10,
"time": 3378.872
},
{
"type": 3,
"mouseX": 92,
"mouseY": -8,
"time": 3402.1118
},
{
"type": 3,
"mouseX": 64,
"mouseY": -5,
"time": 3429.7879
},
{
"type": 3,
"mouseX": 24,
"mouseY": -3,
"time": 3453.0497
},
{
"type": 1,
"keyCode": 68,
"mouseX": 0,
"mouseY": 0,
"time": 3579.1004
},
{
"type": 3,
"mouseX": -1,
"mouseY": -1,
"time": 3681.4494
},
{
"type": 1,
"keyCode": 87,
"mouseX": 0,
"mouseY": 0,
"time": 3746.0817
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 3812.5978
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 3925.0674
},
{
"type": 3,
"mouseX": -1,
"mouseY": 0,
"time": 3952.8614
},
{
"type": 3,
"mouseX": -2,
"mouseY": -1,
"time": 4007.7672
},
{
"type": 3,
"mouseX": 0,
"mouseY": -1,
"time": 4047.2136
},
{
"type": 3,
"mouseX": 0,
"mouseY": -2,
"time": 4086.2098
}
],
"info": {
"name": "",
"description": "",
"x": 319,
"y": 192,
"width": 1920,
"height": 1080
}
}

View File

@ -2,11 +2,13 @@
* 注意本脚本的方案是首次传送到晶蝶位置后的方案
* 如果你在传送点待了很久的话晶蝶会自己飞走即便是有早柚的情况下
* 这种情况下没法完全捕捉到晶蝶
*
* 有些点位未探索可能会导致没有晶蝶请自行探索
*/
(async function () {
// 启用自动拾取的实时任务
//dispatcher.addTimer(new RealtimeTimer("AutoPick"));
dispatcher.addTimer(new RealtimeTimer("AutoPick"));
log.info('开始捕捉晶蝶,请在队伍中务必携带{zy},使用成男/成女角色', '早柚');
@ -25,5 +27,5 @@
await captureCrystalfly('枫丹-幽林雾道', 3376, 3290, 2);
await captureCrystalfly('枫丹-莫尔泰区', 3810, 2334, 2);
await captureCrystalfly('枫丹-特别温暖的地方', 4790, 2520, 3);
await captureCrystalfly('须弥-下风蚀地', 4452, -2456, 3);
// await captureCrystalfly('须弥-下风蚀地', 4452, -2456, 3);
})();

View File

@ -1,6 +1,6 @@
{
"manifest_version": 1,
"name": "自动采集晶蝶",
"name": "自动采集晶蝶(枫丹)",
"version": "1.0",
"description": "BetterGI自带脚本自动采集离传送点较近的晶蝶。",
"authors": [

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using BetterGenshinImpact.Core.Script.Group;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BetterGenshinImpact.Service.Interface;
@ -6,4 +7,6 @@ namespace BetterGenshinImpact.Service.Interface;
public interface IScriptService
{
Task RunMulti(List<string> folderNameList, string? groupName = null);
Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string groupName);
}

View File

@ -9,6 +9,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Documents;
using BetterGenshinImpact.Core.Script.Group;
using BetterGenshinImpact.Core.Script;
namespace BetterGenshinImpact.Service;
@ -75,6 +78,121 @@ public partial class ScriptService(HomePageViewModel homePageViewModel) : IScrip
}
}
public async Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string groupName)
{
// 重新加载脚本项目 并放入一个新的列表
var list = new List<ScriptGroupProject>();
foreach (var project in projectList)
{
if (project.Type == "Javascript")
{
var newProject = new ScriptGroupProject(new ScriptProject(project.FolderName)); ;
newProject.Status = project.Status;
newProject.Schedule = project.Schedule;
newProject.RunNum = project.RunNum;
list.Add(newProject);
}
else
{
var newProject = new ScriptGroupProject(project.FolderName);
newProject.Status = project.Status;
newProject.Schedule = project.Schedule;
newProject.RunNum = project.RunNum;
list.Add(newProject);
}
}
// 判断其中的
List<ScriptProject> jsProjects = [];
foreach (var project in list)
{
if (project is { Type: "Javascript", Project: not null })
{
jsProjects.Add(project.Project);
}
}
var hasTimer = false;
if (jsProjects.Count > 0)
{
var codeList = await ReadCodeList(jsProjects);
hasTimer = HasTimerOperation(codeList);
}
// 没启动时候,启动截图器
await homePageViewModel.OnStartTriggerAsync();
if (hasTimer)
{
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName);
}
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName, list.Count);
// 循环执行所有脚本
var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;
await new TaskRunner(timerOperation)
.RunAsync(async () =>
{
foreach (var project in list)
{
if (project.Status != "Enabled")
{
_logger.LogInformation("脚本 {Name} 状态为禁用,跳过执行", project.Name);
continue;
}
if (CancellationContext.Instance.Cts.IsCancellationRequested)
{
_logger.LogInformation("执行被取消");
break;
}
for (var i = 0; i < project.RunNum; i++)
{
try
{
if (hasTimer)
{
TaskTriggerDispatcher.Instance().ClearTriggers();
}
_logger.LogInformation("------------------------------");
if (project.Type == "Javascript")
{
if (project.Project == null)
{
throw new Exception("Project 为空");
}
_logger.LogInformation("→ 开始执行JS脚本: {Name}", project.Name);
await project.Run();
}
else
{
_logger.LogInformation("→ 开始执行键鼠脚本: {Name}", project.Name);
await project.Run();
}
await Task.Delay(2000);
}
catch (Exception e)
{
_logger.LogDebug(e, "执行脚本时发生异常");
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
}
finally
{
_logger.LogInformation("→ 脚本执行结束: {Name}", project.Name);
_logger.LogInformation("------------------------------");
}
}
}
});
_logger.LogInformation("配置组 {Name} 执行结束", groupName);
}
private async Task<List<string>> ReadCodeList(List<ScriptProject> list)
{
var codeList = new List<string>();

View File

@ -40,7 +40,7 @@
<ui:TextBlock Grid.Row="1"
Margin="0,0,0,8"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="可以通过 Javascript 调用 BetterGI 在原神中的各项能力"
Text="可以通过 Javascript 调用 BetterGI 在原神中的各项能力,右键可以直接执行脚本"
TextWrapping="Wrap" />
<StackPanel Grid.Row="2" Orientation="Horizontal">

View File

@ -36,7 +36,7 @@
<ui:TextBlock Grid.Row="0"
Margin="0,0,0,8"
FontTypography="BodyStrong"
Text="键鼠录制回放功能(实验功能)" />
Text="键鼠录制回放功能(实验功能)" />
<ui:TextBlock Grid.Row="1"
Margin="0,0,0,8"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"

View File

@ -96,12 +96,12 @@
<StackPanel>
<ui:TextBlock Margin="0,0,0,8"
FontTypography="BodyStrong"
Text="(实验功能)请在左侧栏选择或新增配置组" />
Text="(实验功能)请在左侧栏选择或新增配置组" />
<ui:TextBlock Margin="0,0,0,8"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap">
左侧配置组栏目右键可以新增配置组,然后可以添加并配置软件内的脚本,并进行连续执行。脚本语言为 Javascript<Hyperlink Command="{Binding GoToScriptGroupUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
点击查看配置组使用教程
左侧配置组栏目右键可以新增配置组,然后可以添加并配置软件内的 Javascript 脚本、键鼠脚本等,并能够控制执行次数、顺序等<Hyperlink Command="{Binding GoToScriptGroupUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
点击查看调度器使用教程
</Hyperlink>
</ui:TextBlock>
<!-- 示例配置组 -->
@ -151,7 +151,7 @@
<StackPanel Grid.Row="0" Orientation="Horizontal">
<ui:TextBlock Margin="0,0,0,8"
FontTypography="BodyStrong"
Text="(实验功能)配置组 - " />
Text="(实验功能)配置组 - " />
<ui:TextBlock Margin="0,0,0,8"
FontTypography="BodyStrong"
Text="{Binding SelectedScriptGroup.Name}" />
@ -161,26 +161,22 @@
Margin="0,0,0,8"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap">
在下方列表中右键可以添加配置,拖拽可以调整执行顺序,支持 Javascript 编写的脚本,<Hyperlink Command="{Binding GoToScriptProjectUrlCommand}" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
点击查看使用教程
</Hyperlink>
在下方列表中右键可以添加配置,拖拽可以调整执行顺序。支持 BetterGI 内的 Javascript 脚本、键鼠录制脚本等,通过调度器可以设置脚本执行次数、顺序等。
</ui:TextBlock>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<ui:Button Command="{Binding StartScriptGroupCommand}"
Content="运行此组配置"
Icon="{ui:SymbolIcon Play24}"
IsEnabled="{Binding IsRecording, Converter={StaticResource InverseBooleanConverter}}" />
Icon="{ui:SymbolIcon Play24}" />
<Separator Width="10" Opacity="0" />
<ui:Button Command="{Binding StopRecordCommand}"
Content="停止运行"
Icon="{ui:SymbolIcon Stop24}"
IsEnabled="{Binding IsRecording}" />
<Separator Width="10" Opacity="0" />
<ui:Button Command="{Binding OpenScriptFolderCommand}"
Content="打开脚本目录"
Icon="{ui:SymbolIcon FolderOpen24}" />
<ui:TextBlock VerticalAlignment="Center"
FontSize="16"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap">
停止运行请配置并使用快捷键!
</ui:TextBlock>
</StackPanel>
<Separator Grid.Row="3"
@ -220,7 +216,7 @@
DisplayMemberBinding="{Binding Name}"
Header="名称" />
<GridViewColumn Width="{Binding ElementName=Col3, Path=ActualWidth}"
DisplayMemberBinding="{Binding Type}"
DisplayMemberBinding="{Binding TypeDesc}"
Header="类型" />
<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}"
DisplayMemberBinding="{Binding ScheduleDesc}"
@ -235,10 +231,14 @@
</ListView.View>
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding AddScriptCommand}" Header="添加配置" />
<MenuItem Command="{Binding AddJsScriptCommand}" Header="添加JS脚本" />
<MenuItem Command="{Binding AddKmScriptCommand}" Header="添加键鼠脚本" />
<MenuItem Command="{Binding EditScriptCommonCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
Header="修改通用配置" />
<MenuItem Command="{Binding DeleteScriptCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
Header="移除配置" />
Header="移除" />
</ContextMenu>
</ListBox.ContextMenu>
<ListView.Style>

View File

@ -0,0 +1,40 @@
<UserControl x:Class="BetterGenshinImpact.View.Windows.Editable.ScriptGroupProjectEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BetterGenshinImpact.Core.Script.Group"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="200"
Height="300"
d:DesignHeight="200"
d:DesignWidth="300"
mc:Ignorable="d">
<UserControl.Resources>
<ObjectDataProvider x:Key="StatusDescriptionsProvider"
MethodName="GetStatusDescriptions"
ObjectType="{x:Type local:ScriptGroupProjectExtensions}" />
<ObjectDataProvider x:Key="ScheduleDescriptionsProvider"
MethodName="GetScheduleDescriptions"
ObjectType="{x:Type local:ScriptGroupProjectExtensions}" />
</UserControl.Resources>
<Grid>
<StackPanel>
<TextBlock Margin="0,0,0,10" Text="执行周期" />
<ComboBox Margin="0,0,0,20"
DisplayMemberPath="Value"
ItemsSource="{Binding Source={StaticResource ScheduleDescriptionsProvider}}"
SelectedValue="{Binding Schedule, Mode=TwoWay}"
SelectedValuePath="Key" />
<TextBlock Margin="0,0,0,10" Text="执行次数" />
<TextBox Margin="0,0,0,20" Text="{Binding RunNum, Mode=TwoWay}" />
<TextBlock Margin="0,0,0,10" Text="状态" />
<ComboBox DisplayMemberPath="Value"
ItemsSource="{Binding Source={StaticResource StatusDescriptionsProvider}}"
SelectedValue="{Binding Status, Mode=TwoWay}"
SelectedValuePath="Key" />
</StackPanel>
</Grid>
</UserControl>

View File

@ -0,0 +1,14 @@
using System.Windows.Controls;
namespace BetterGenshinImpact.View.Windows.Editable;
/// <summary>
/// ScriptGroupProjectEditor.xaml 的交互逻辑
/// </summary>
public partial class ScriptGroupProjectEditor : UserControl
{
public ScriptGroupProjectEditor()
{
InitializeComponent();
}
}

View File

@ -130,6 +130,17 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
);
HotKeySettingModels.Add(bgiEnabledHotKeySettingModel);
HotKeySettingModels.Add(new HotKeySettingModel(
"停止当前脚本任务",
nameof(Config.HotKeyConfig.CancelTaskHotkey),
Config.HotKeyConfig.CancelTaskHotkey,
Config.HotKeyConfig.CancelTaskHotkeyType,
(_, _) =>
{
CancellationContext.Instance.Cancel();
}
));
var takeScreenshotHotKeySettingModel = new HotKeySettingModel(
"游戏截图(开发者)",
nameof(Config.HotKeyConfig.TakeScreenshotHotkey),
@ -369,17 +380,6 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
}
));
HotKeySettingModels.Add(new HotKeySettingModel(
"停止当前脚本任务",
nameof(Config.HotKeyConfig.CancelTaskHotkey),
Config.HotKeyConfig.CancelTaskHotkey,
Config.HotKeyConfig.CancelTaskHotkeyType,
(_, _) =>
{
CancellationContext.Instance.Cancel();
}
));
if (RuntimeHelper.IsDebug)
{
HotKeySettingModels.Add(new HotKeySettingModel(

View File

@ -3,9 +3,11 @@ using BetterGenshinImpact.Core.Script.Group;
using BetterGenshinImpact.Core.Script.Project;
using BetterGenshinImpact.Service.Interface;
using BetterGenshinImpact.View.Windows;
using BetterGenshinImpact.View.Windows.Editable;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Logging;
using SharpDX.Direct3D11;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -53,9 +55,10 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
ReadScriptGroup();
}
public ScriptControlViewModel(ISnackbarService snackbarService, HomePageViewModel homePageViewModel)
public ScriptControlViewModel(ISnackbarService snackbarService, IScriptService scriptService, HomePageViewModel homePageViewModel)
{
_snackbarService = snackbarService;
_scriptService = scriptService;
_homePageViewModel = homePageViewModel;
ScriptGroups.CollectionChanged += ScriptGroupsCollectionChanged;
}
@ -118,9 +121,9 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
}
[RelayCommand]
private void OnAddScript()
private void OnAddJsScript()
{
var list = LoadAllScriptProjects();
var list = LoadAllJsScriptProjects();
var combobox = new ComboBox();
foreach (var scriptProject in list)
@ -128,7 +131,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
combobox.Items.Add(scriptProject.FolderName + " - " + scriptProject.Manifest.Name);
}
var str = PromptDialog.Prompt("请选择需要添加的脚本", "请选择需要添加的脚本", combobox);
var str = PromptDialog.Prompt("请选择需要添加的JS脚本", "请选择需要添加的JS脚本", combobox);
if (!string.IsNullOrEmpty(str))
{
var folderName = str.Split(" - ")[0];
@ -136,7 +139,25 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
}
}
private List<ScriptProject> LoadAllScriptProjects()
[RelayCommand]
private void OnAddKmScript()
{
var list = LoadAllKmScripts();
var combobox = new ComboBox();
foreach (var fileInfo in list)
{
combobox.Items.Add(fileInfo.Name);
}
var str = PromptDialog.Prompt("请选择需要添加的键鼠脚本", "请选择需要添加的键鼠脚本", combobox);
if (!string.IsNullOrEmpty(str))
{
SelectedScriptGroup?.Projects.Add(new ScriptGroupProject(str));
}
}
private List<ScriptProject> LoadAllJsScriptProjects()
{
var path = Global.ScriptPath();
// 获取所有脚本项目
@ -146,6 +167,43 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
return projects;
}
private List<FileInfo> LoadAllKmScripts()
{
var folder = Global.Absolute(@"User\KeyMouseScript");
// 获取所有脚本项目
var files = Directory.GetFiles(folder, "*.*",
SearchOption.AllDirectories);
return files.Select(file => new FileInfo(file)).ToList();
}
[RelayCommand]
public void OnEditScriptCommon(ScriptGroupProject? item)
{
if (item == null)
{
return;
}
ShowEditWindow(item);
foreach (var group in ScriptGroups)
{
WriteScriptGroup(group);
}
}
public static void ShowEditWindow(object viewModel)
{
var uiMessageBox = new MessageBox
{
Title = "修改通用设置",
Content = new ScriptGroupProjectEditor { DataContext = viewModel },
CloseButtonText = "确定",
};
uiMessageBox.ShowDialogAsync();
}
[RelayCommand]
public void OnDeleteScript(ScriptGroupProject? item)
{
@ -299,12 +357,6 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/") { UseShellExecute = true });
}
[RelayCommand]
public void OnGoToScriptProjectUrl()
{
Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/") { UseShellExecute = true });
}
[RelayCommand]
public void OnImportScriptGroup(string scriptGroupExample)
{
@ -344,8 +396,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
);
return;
}
var projects = SelectedScriptGroup.Projects.Select(project => project.FolderName).ToList();
await _scriptService.RunMulti(projects, SelectedScriptGroup.Name);
await _scriptService.RunMulti(SelectedScriptGroup.Projects, SelectedScriptGroup.Name);
}
}