Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98b1376111 | ||
|
|
b62e4a7425 | ||
|
|
6aa02b94d9 | ||
|
|
be89383add | ||
|
|
0097bfa8c3 | ||
|
|
6812f30732 | ||
|
|
c6680ced12 | ||
|
|
b47ce6f529 | ||
|
|
9b874d3747 | ||
|
|
2b6465be22 | ||
|
|
d2574022fc | ||
|
|
87ae5e437a | ||
|
|
c486b860d0 | ||
|
|
4784551e10 | ||
|
|
030caec91f | ||
|
|
8b0bdef670 | ||
|
|
6651ec7d9f | ||
|
|
d4fe1f2ab0 | ||
|
|
4e1a0673c9 | ||
|
|
f904fe024b | ||
|
|
bb41bcb25e | ||
|
|
743debb58b | ||
|
|
180fc2d228 | ||
|
|
d148014b7f | ||
|
|
9fa721d5e4 | ||
|
|
8a5d1d5f64 | ||
|
|
cc245b0e8a | ||
|
|
49bc6befb7 | ||
|
|
f82e35382c | ||
|
|
224fc9917a | ||
|
|
eb0b681b9d | ||
|
|
f61a7c32d4 |
No files matched your search
@@ -2,12 +2,14 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:bgivc="clr-namespace:BetterGenshinImpact.View.Converters"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemesDictionary Theme="Dark" />
|
||||
<ui:ControlsDictionary />
|
||||
<vio:ControlsDictionary />
|
||||
<ResourceDictionary Source="/View/Controls/WpfUi/FaFontIconStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<FontFamily x:Key="TextThemeFontFamily">/Assets/Fonts/MiSans-Regular.ttf#MiSans</FontFamily>
|
||||
|
||||
@@ -87,13 +87,14 @@ public partial class App : Application
|
||||
services.AddView<HotKeyPage, HotKeyPageViewModel>();
|
||||
services.AddView<NotificationSettingsPage, NotificationSettingsPageViewModel>();
|
||||
services.AddView<KeyMouseRecordPage, KeyMouseRecordPageViewModel>();
|
||||
// services.AddView<DispatcherPage, DispatcherPageViewModel>();
|
||||
services.AddView<JsListPage, JsListViewModel>();
|
||||
|
||||
// My Services
|
||||
services.AddSingleton<TaskTriggerDispatcher>();
|
||||
services.AddSingleton<NotificationService>();
|
||||
services.AddHostedService(sp => sp.GetRequiredService<NotificationService>());
|
||||
services.AddSingleton<NotifierManager>();
|
||||
services.AddSingleton<IScriptService, ScriptService>();
|
||||
|
||||
// Configuration
|
||||
//services.Configure<AppConfig>(context.Configuration.GetSection(nameof(AppConfig)));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
|
||||
@@ -47,7 +47,7 @@
|
||||
<PackageReference Include="Microsoft.ClearScript.V8" Version="7.4.5" />
|
||||
<PackageReference Include="Microsoft.ClearScript.V8.Native.win-x64" Version="7.4.5" />
|
||||
<PackageReference Include="MouseKeyHook" Version="5.7.1" />
|
||||
<PackageReference Include="PresentMonFps" Version="2.0.1" />
|
||||
<PackageReference Include="PresentMonFps" Version="2.0.5" />
|
||||
<PackageReference Include="Sdcb.PaddleInference" Version="2.5.0.1" />
|
||||
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.openblas" Version="2.5.1" />
|
||||
<PackageReference Include="Sdcb.PaddleOCR" Version="2.7.0" />
|
||||
@@ -60,12 +60,12 @@
|
||||
<PackageReference Include="Vanara.PInvoke.User32" Version="4.0.2" />
|
||||
<PackageReference Include="WPF-UI" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Tray" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="3.0.5.2" />
|
||||
<PackageReference Include="YoloV8" Version="4.1.7" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -74,27 +74,6 @@
|
||||
<ProjectReference Include="..\Fischless.WindowsInput\Fischless.WindowsInput.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="GameTask\TaskContext.cs">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Update="View\MaskWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Pages\HotkeyPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Pages\TriggerSettingsPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\PickerWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Windows\MapViewer.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\Map\**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -152,10 +131,4 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="GameTask\Common\Element\Assets\MapPoint\" />
|
||||
<Folder Include="Script\AutoCrystalfly\" />
|
||||
<Folder Include="View\Controls\WpfUi\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -5,7 +5,7 @@ namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
public class Global
|
||||
{
|
||||
public static string Version { get; } = "0.32.5";
|
||||
public static string Version { get; } = "0.33.1";
|
||||
|
||||
public static string StartUpPath { get; set; } = AppContext.BaseDirectory;
|
||||
|
||||
|
||||
@@ -170,6 +170,27 @@ public partial class HotKeyConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _test2HotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径记录开始
|
||||
[ObservableProperty]
|
||||
private string _pathRecorderHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _pathRecorderHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 添加路径记录点
|
||||
[ObservableProperty]
|
||||
private string _addWaypointHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _addWaypointHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径执行
|
||||
[ObservableProperty]
|
||||
private string _executePathHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _executePathHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 日志与状态窗口展示
|
||||
[ObservableProperty]
|
||||
private string _logBoxDisplayHotkey = "";
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
|
||||
/// <summary>
|
||||
/// FlannMatch
|
||||
/// 优点:
|
||||
/// 1. 速度快:FlannMatch 使用的是近似最近邻搜索算法,适合处理大规模数据集,速度比暴力匹配器快得多。
|
||||
/// 2. 可扩展性好:适用于高维特征空间,能够处理大量特征点。
|
||||
/// 缺点:
|
||||
/// 1. 精度较低:由于是近似搜索,匹配的精度可能不如暴力匹配器高。
|
||||
/// 2. 复杂性高:需要对参数进行调优,以获得最佳性能。
|
||||
/// BfMatch
|
||||
/// 优点:
|
||||
/// 1. 精度高:BfMatch 进行的是精确匹配,能够找到最优的匹配对。
|
||||
/// 2. 简单易用:不需要复杂的参数调优,适合初学者和简单应用。
|
||||
/// 缺点:
|
||||
/// 1. 速度慢:对于大规模数据集,暴力匹配器的速度较慢,因为它需要计算所有特征点之间的距离。
|
||||
/// 2. 不适合高维数据:在高维特征空间中,计算量会显著增加,性能下降明显。
|
||||
/// 选择建议
|
||||
/// • 大规模数据集:如果你需要处理大量特征点,且对速度要求较高,FlannMatch 是一个更好的选择。
|
||||
/// • 高精度要求:如果你的应用对匹配精度要求很高,且数据规模较小,BfMatch 会更合适。
|
||||
/// </summary>
|
||||
public enum DescriptorMatcherType
|
||||
{
|
||||
// 快速近似最近邻搜索库
|
||||
BruteForce,
|
||||
|
||||
// 暴力匹配器
|
||||
FlannBased
|
||||
|
||||
// 更多类型命名见 DescriptorMatcher.Create
|
||||
}
|
||||
@@ -7,15 +7,21 @@ using OpenCvSharp.XFeatures2D;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
|
||||
public class FeatureMatcher
|
||||
{
|
||||
private readonly double _threshold; // SURF 100
|
||||
private readonly double _threshold = 100; // SURF 100
|
||||
private readonly Feature2D _feature2D;
|
||||
private readonly FlannBasedMatcher flnMatcher = new();
|
||||
|
||||
private readonly Dictionary<DescriptorMatcherType, DescriptorMatcher> _matcherFactory = new()
|
||||
{
|
||||
{ DescriptorMatcherType.BruteForce, DescriptorMatcher.Create(DescriptorMatcherType.BruteForce.ToString()) },
|
||||
{ DescriptorMatcherType.FlannBased, DescriptorMatcher.Create(DescriptorMatcherType.FlannBased.ToString()) }
|
||||
};
|
||||
|
||||
private readonly Size _trainMatSize; // 大图大小
|
||||
|
||||
@@ -34,11 +40,9 @@ public class FeatureMatcher
|
||||
/// <param name="trainMat"></param>
|
||||
/// <param name="featureStorage"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="threshold"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public FeatureMatcher(Mat trainMat, FeatureStorage? featureStorage = null, Feature2DType type = Feature2DType.SIFT, double threshold = 100)
|
||||
public FeatureMatcher(Mat trainMat, FeatureStorage? featureStorage = null, Feature2DType type = Feature2DType.SIFT)
|
||||
{
|
||||
_threshold = threshold;
|
||||
_trainMatSize = trainMat.Size();
|
||||
if (Feature2DType.SURF == type)
|
||||
{
|
||||
@@ -86,11 +90,9 @@ public class FeatureMatcher
|
||||
/// <param name="trainMatSize"></param>
|
||||
/// <param name="featureStorage"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="threshold"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public FeatureMatcher(Size trainMatSize, FeatureStorage featureStorage, Feature2DType type = Feature2DType.SIFT, double threshold = 100)
|
||||
public FeatureMatcher(Size trainMatSize, FeatureStorage featureStorage, Feature2DType type = Feature2DType.SIFT)
|
||||
{
|
||||
_threshold = threshold;
|
||||
_trainMatSize = trainMatSize;
|
||||
if (Feature2DType.SURF == type)
|
||||
{
|
||||
@@ -114,6 +116,13 @@ public class FeatureMatcher
|
||||
Debug.WriteLine($"切割特征点耗时: {sw.ElapsedMilliseconds}ms");
|
||||
}
|
||||
|
||||
public DescriptorMatcher GetMatcher(DescriptorMatcherType type)
|
||||
{
|
||||
return _matcherFactory[type];
|
||||
}
|
||||
|
||||
#region 普通匹配
|
||||
|
||||
/// <summary>
|
||||
/// 普通匹配(全图特征)
|
||||
/// </summary>
|
||||
@@ -150,11 +159,13 @@ public class FeatureMatcher
|
||||
/// 普通匹配
|
||||
/// </summary>
|
||||
/// <param name="trainKeyPoints"></param>
|
||||
/// <param name="trainRet"></param>
|
||||
/// <param name="trainDescriptors"></param>
|
||||
/// <param name="queryMat"></param>
|
||||
/// <param name="queryMatMask"></param>
|
||||
/// <param name="matcherType"></param>
|
||||
/// <returns></returns>
|
||||
public Point2f Match(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
public Point2f Match(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
|
||||
@@ -164,7 +175,7 @@ public class FeatureMatcher
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
|
||||
var matches = flnMatcher.Match(queryDescriptors, trainRet);
|
||||
var matches = GetMatcher(matcherType).Match(queryDescriptors, trainDescriptors);
|
||||
//Finding the Minimum and Maximum Distance
|
||||
double minDistance = 1000; //Backward approximation
|
||||
double maxDistance = 0;
|
||||
@@ -237,11 +248,13 @@ public class FeatureMatcher
|
||||
/// 普通匹配
|
||||
/// </summary>
|
||||
/// <param name="trainKeyPoints"></param>
|
||||
/// <param name="trainRet"></param>
|
||||
/// <param name="trainDescriptors"></param>
|
||||
/// <param name="queryMat"></param>
|
||||
/// <param name="queryMatMask"></param>
|
||||
/// <param name="matcherType"></param>
|
||||
/// <returns></returns>
|
||||
public Point2f[] MatchCorners(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
public Point2f[] MatchCorners(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
|
||||
@@ -251,7 +264,7 @@ public class FeatureMatcher
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
|
||||
var matches = flnMatcher.Match(queryDescriptors, trainRet);
|
||||
var matches = GetMatcher(matcherType).Match(queryDescriptors, trainDescriptors);
|
||||
//Finding the Minimum and Maximum Distance
|
||||
double minDistance = 1000; //Backward approximation
|
||||
double maxDistance = 0;
|
||||
@@ -328,91 +341,46 @@ public class FeatureMatcher
|
||||
return Cv2.BoundingRect(corners);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// knn的方式匹配
|
||||
// /// </summary>
|
||||
// /// <param name="matSrc"></param>
|
||||
// /// <returns></returns>
|
||||
// [Obsolete]
|
||||
// public Point2f[]? KnnMatch(Mat matSrc)
|
||||
// {
|
||||
// SpeedTimer speedTimer = new();
|
||||
//
|
||||
// using var matSrcRet = new Mat();
|
||||
// KeyPoint[] keyPointsSrc;
|
||||
// using (var surf = SURF.Create(_threshold, 4, 3, false, true))
|
||||
// {
|
||||
// surf.DetectAndCompute(matSrc, null, out keyPointsSrc, matSrcRet);
|
||||
// speedTimer.Record("模板生成KeyPoint");
|
||||
// }
|
||||
//
|
||||
// var knnMatches = flnMatcher.KnnMatch(matSrcRet, _trainDescriptors, 2);
|
||||
// const float minRatio = 0.75f;
|
||||
//
|
||||
// var pointsSrc = new List<Point2f>();
|
||||
// var pointsDst = new List<Point2f>();
|
||||
// //Screening better matching points
|
||||
// // var goodMatches = new List<DMatch>();
|
||||
// for (int i = 0; i < knnMatches.Length; i++)
|
||||
// {
|
||||
// var best = knnMatches[i][0];
|
||||
// var better = knnMatches[i][1];
|
||||
// var r = best.Distance / better.Distance;
|
||||
// if (r > minRatio)
|
||||
// {
|
||||
// pointsSrc.Add(keyPointsSrc[best.QueryIdx].Pt);
|
||||
// pointsDst.Add(_trainKeyPoints[best.TrainIdx].Pt);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (pointsSrc.Count < 7)
|
||||
// {
|
||||
// Debug.WriteLine("匹配点过少");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// speedTimer.Record("FlannMatch.KnnMatch");
|
||||
//
|
||||
// // var outMat = new Mat();
|
||||
//
|
||||
// // algorithm RANSAC Filter the matched results
|
||||
// var pSrc = pointsSrc.ToPoint2d();
|
||||
// var pDst = pointsDst.ToPoint2d();
|
||||
// var outMask = new Mat();
|
||||
// // If the original matching result is null, Skip the filtering step
|
||||
// if (pSrc.Count > 0 && pDst.Count > 0)
|
||||
// {
|
||||
// var hMat = Cv2.FindHomography(pSrc, pDst, HomographyMethods.Ransac, mask: outMask);
|
||||
// speedTimer.Record("FindHomography");
|
||||
//
|
||||
// var objCorners = new Point2f[4];
|
||||
// objCorners[0] = new Point2f(0, 0);
|
||||
// objCorners[1] = new Point2f(0, matSrc.Rows);
|
||||
// objCorners[2] = new Point2f(matSrc.Cols, matSrc.Rows);
|
||||
// objCorners[3] = new Point2f(matSrc.Cols, 0);
|
||||
//
|
||||
// var sceneCorners = Cv2.PerspectiveTransform(objCorners, hMat);
|
||||
// speedTimer.Record("PerspectiveTransform");
|
||||
// speedTimer.DebugPrint();
|
||||
// return sceneCorners;
|
||||
// }
|
||||
//
|
||||
// speedTimer.DebugPrint();
|
||||
// return null;
|
||||
// }
|
||||
#endregion 普通匹配
|
||||
|
||||
#region Knn匹配
|
||||
|
||||
public Point2f KnnMatch(Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
return KnnMatch(_trainKeyPoints, _trainDescriptors, queryMat, queryMatMask, matcherType);
|
||||
}
|
||||
|
||||
public Point2f KnnMatch(Mat queryMat, float prevX, float prevY, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
var (cellRow, cellCol) = KeyPointFeatureBlockHelper.GetCellIndex(_trainMatSize, _splitRow, _splitCol, prevX, prevY);
|
||||
Debug.WriteLine($"当前坐标({prevX},{prevY})在特征块({cellRow},{cellCol})中");
|
||||
if (_lastMergedBlock == null || _lastMergedBlock.MergedCenterCellRow != cellRow || _lastMergedBlock.MergedCenterCellCol != cellCol)
|
||||
{
|
||||
Debug.WriteLine($"---------切换到新的特征块({cellRow},{cellCol}),合并特征点--------");
|
||||
_lastMergedBlock = KeyPointFeatureBlockHelper.MergeNeighboringFeatures(_blocks, _trainDescriptors, cellRow, cellCol);
|
||||
}
|
||||
|
||||
return KnnMatch(_lastMergedBlock.KeyPointArray, _lastMergedBlock.Descriptor!, queryMat, queryMatMask, matcherType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://github.com/tignioj/minimap/blob/main/matchmap/sifttest/sifttest5.py
|
||||
/// Copilot 生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Point2f? KnnMatch(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
private Point2f KnnMatch(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
using var queryDescriptors = new Mat();
|
||||
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
||||
_feature2D.DetectAndCompute(queryMat, queryMatMask, out var queryKeyPoints, queryDescriptors);
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
var matches = flnMatcher.KnnMatch(queryDescriptors, _trainDescriptors, k: 2);
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
var matches = GetMatcher(matcherType).KnnMatch(queryDescriptors, trainDescriptors, k: 2);
|
||||
speedTimer.Record("FlannMatch");
|
||||
|
||||
// 应用比例测试来过滤匹配点
|
||||
List<DMatch> goodMatches = [];
|
||||
@@ -426,29 +394,101 @@ public class FeatureMatcher
|
||||
|
||||
if (goodMatches.Count < 7)
|
||||
{
|
||||
return null;
|
||||
return new Point2f();
|
||||
}
|
||||
|
||||
// 获取匹配点的坐标
|
||||
var srcPts = goodMatches.Select(m => queryKeyPoints[m.QueryIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => _trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
|
||||
speedTimer.Record("GetGoodMatchPoints");
|
||||
|
||||
// 使用RANSAC找到变换矩阵
|
||||
var mask = new Mat();
|
||||
var M = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (M.Empty())
|
||||
var hMat = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (hMat.Empty())
|
||||
{
|
||||
return null;
|
||||
return new Point2f();
|
||||
}
|
||||
speedTimer.Record("FindHomography");
|
||||
|
||||
// 计算小地图的中心点
|
||||
var h = queryMat.Rows;
|
||||
var w = queryMat.Cols;
|
||||
var centerPoint = new Point2f(w / 2f, h / 2f);
|
||||
Point2f[] centerPoints = [centerPoint];
|
||||
Point2f[] transformedCenter = Cv2.PerspectiveTransform(centerPoints, M);
|
||||
Point2f[] transformedCenter = Cv2.PerspectiveTransform(centerPoints, hMat);
|
||||
|
||||
speedTimer.Record("PerspectiveTransform");
|
||||
speedTimer.DebugPrint();
|
||||
// 返回小地图在大地图中的中心坐标
|
||||
return transformedCenter[0];
|
||||
}
|
||||
|
||||
public Point2f[] KnnMatchCorners(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
using var queryDescriptors = new Mat();
|
||||
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
||||
_feature2D.DetectAndCompute(queryMat, queryMatMask, out var queryKeyPoints, queryDescriptors);
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
var matches = GetMatcher(matcherType).KnnMatch(queryDescriptors, trainDescriptors, k: 2);
|
||||
speedTimer.Record("FlannMatch");
|
||||
|
||||
// 应用比例测试来过滤匹配点
|
||||
List<DMatch> goodMatches = [];
|
||||
foreach (var match in matches)
|
||||
{
|
||||
if (match.Length == 2 && match[0].Distance < 0.75 * match[1].Distance)
|
||||
{
|
||||
goodMatches.Add(match[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (goodMatches.Count < 7)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取匹配点的坐标
|
||||
var srcPts = goodMatches.Select(m => queryKeyPoints[m.QueryIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
|
||||
speedTimer.Record("GetGoodMatchPoints");
|
||||
|
||||
// 使用RANSAC找到变换矩阵
|
||||
var mask = new Mat();
|
||||
var hMat = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (hMat.Empty())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
speedTimer.Record("FindHomography");
|
||||
|
||||
// 返回四个角点
|
||||
var objCorners = new Point2f[4];
|
||||
objCorners[0] = new Point2f(0, 0);
|
||||
objCorners[1] = new Point2f(0, queryMat.Rows);
|
||||
objCorners[2] = new Point2f(queryMat.Cols, queryMat.Rows);
|
||||
objCorners[3] = new Point2f(queryMat.Cols, 0);
|
||||
|
||||
var sceneCorners = Cv2.PerspectiveTransform(objCorners, hMat);
|
||||
speedTimer.Record("PerspectiveTransform");
|
||||
speedTimer.DebugPrint();
|
||||
return sceneCorners;
|
||||
}
|
||||
|
||||
public Rect KnnMatchRect(Mat queryMat, Mat? queryMatMask = null)
|
||||
{
|
||||
var corners = KnnMatchCorners(_trainKeyPoints, _trainDescriptors, queryMat, queryMatMask);
|
||||
if (corners.Length == 0)
|
||||
{
|
||||
return Rect.Empty;
|
||||
}
|
||||
return Cv2.BoundingRect(corners);
|
||||
}
|
||||
|
||||
#endregion Knn匹配
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
@@ -39,13 +40,13 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
MessageBox.Show("请先在启动页,启动截图器再使用本功能");
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status != KeyMouseRecorderStatus.Stop)
|
||||
{
|
||||
MessageBox.Show("已经在录制状态,请不要重复启动录制功能");
|
||||
Toast.Warning("已经在录制状态,请不要重复启动录制功能");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Vanara.PInvoke;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
@@ -22,7 +23,7 @@ public class KeyMouseMacroPlayer
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
MessageBox.Show("请先在启动页,启动截图器再使用本功能");
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence
|
||||
{
|
||||
internal class AutoPathing(string rootPath)
|
||||
{
|
||||
public async Task Run(string json)
|
||||
{
|
||||
var task = JsonSerializer.Deserialize<PathingTask>(json);
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await PathExecutor.Pathing(task, CancellationContext.Instance.Cts);
|
||||
}
|
||||
|
||||
public async Task RunFile(string path)
|
||||
{
|
||||
var json = await new LimitedFile(rootPath).ReadText(path);
|
||||
await Run(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class EngineExtend
|
||||
|
||||
// 添加我的自定义实例化对象
|
||||
engine.AddHostObject("keyMouseScript", new KeyMouseScript(workDir));
|
||||
engine.AddHostObject("autoPathing", new AutoPathing(workDir));
|
||||
engine.AddHostObject("genshin", new Dependence.Genshin());
|
||||
engine.AddHostObject("log", new Log());
|
||||
engine.AddHostObject("file", new LimitedFile(workDir)); // 限制文件访问
|
||||
|
||||
@@ -34,6 +34,6 @@ public partial class ScriptGroup : ObservableObject
|
||||
|
||||
public static ScriptGroup FromJson(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<ScriptGroup>(json, ConfigService.JsonOptions) ?? throw new Exception("解析脚本组JSON配置失败");
|
||||
return JsonSerializer.Deserialize<ScriptGroup>(json, ConfigService.JsonOptions) ?? throw new Exception("解析配置组JSON配置失败");
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -11,12 +16,16 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
[ObservableProperty]
|
||||
private int _index;
|
||||
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _type = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public string TypeDesc => ScriptGroupProjectExtensions.TypeDescriptions[Type];
|
||||
|
||||
[ObservableProperty]
|
||||
private string _status = string.Empty;
|
||||
|
||||
@@ -27,11 +36,15 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
/// 执行周期
|
||||
/// 不在 ScheduleDescriptions 中则会被视为自定义Cron表达式
|
||||
/// </summary>
|
||||
public string Schedule { get; set; } = string.Empty;
|
||||
[ObservableProperty]
|
||||
private string _schedule = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public string ScheduleDesc => ScriptGroupProjectExtensions.ScheduleDescriptions.GetValueOrDefault(Schedule, "自定义周期");
|
||||
|
||||
[ObservableProperty]
|
||||
private int _runNum = 1;
|
||||
|
||||
[JsonIgnore]
|
||||
public ScriptProject? Project { get; set; }
|
||||
|
||||
@@ -41,12 +54,22 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
|
||||
public ScriptGroupProject(ScriptProject project)
|
||||
{
|
||||
Id = project.Manifest.Id;
|
||||
Name = project.Manifest.Name;
|
||||
FolderName = project.FolderName;
|
||||
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>
|
||||
@@ -60,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", "每日" },
|
||||
@@ -82,4 +153,9 @@ public static class ScriptGroupProjectExtensions
|
||||
{ "Saturday", "每周六" },
|
||||
{ "Sunday", "每周日" }
|
||||
};
|
||||
|
||||
public Dictionary<string, string> GetScheduleDescriptions()
|
||||
{
|
||||
return ScheduleDescriptions;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ namespace BetterGenshinImpact.Core.Script.Project;
|
||||
public class Manifest
|
||||
{
|
||||
public int ManifestVersion { get; set; } = 1;
|
||||
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Version { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
@@ -28,11 +26,6 @@ public class Manifest
|
||||
|
||||
public void Validate(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Id))
|
||||
{
|
||||
throw new Exception("manifest.json: id is not supported.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
throw new Exception("manifest.json: name is required.");
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
[Serializable]
|
||||
public class PathingTask
|
||||
{
|
||||
public PathingTaskInfo? Info { get; set; }
|
||||
public List<Waypoint> Waypoints { get; set; } = [];
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class Waypoint
|
||||
{
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public WaypointType WaypointType { get; set; }
|
||||
public MoveType MoveType { get; set; }
|
||||
public ActionType? ActionType { get; set; }
|
||||
}
|
||||
|
||||
public enum WaypointType
|
||||
{
|
||||
Transit,
|
||||
Target,
|
||||
Teleport,
|
||||
}
|
||||
|
||||
public enum MoveType
|
||||
{
|
||||
Walk,
|
||||
Fly,
|
||||
Jump,
|
||||
Swim,
|
||||
}
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
StopFlying,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PathingTaskInfo
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
internal class Navigation
|
||||
{
|
||||
|
||||
internal static Point2f GetPosition()
|
||||
{
|
||||
var greyMat = TaskControl.CaptureToRectArea().SrcGreyMat;
|
||||
greyMat = new Mat(greyMat, new Rect(62, 19, 212, 212));
|
||||
return EntireMap.Instance.GetMiniMapPositionByFeatureMatch(greyMat);
|
||||
}
|
||||
|
||||
internal static int GetTargetOrientation(Waypoint waypoint, Point2f position)
|
||||
{
|
||||
|
||||
var target = MapCoordinate.GameToMain2048(waypoint.X, waypoint.Y);
|
||||
double deltaX = target.x - position.X;
|
||||
double deltaY = target.y - position.Y;
|
||||
double vectorLength = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
if (vectorLength == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// 计算向量与x轴之间的夹角(逆时针方向)
|
||||
double angle = Math.Acos(deltaX / vectorLength);
|
||||
// 如果向量在x轴下方,角度需要调整
|
||||
if (deltaY < 0)
|
||||
{
|
||||
angle = 2 * Math.PI - angle;
|
||||
}
|
||||
// 将角度转换为顺时针方向
|
||||
angle = 2 * Math.PI - angle;
|
||||
return (int)(angle * (180.0 / Math.PI));
|
||||
}
|
||||
|
||||
internal static double GetDistance(Waypoint waypoint, Point2f position)
|
||||
{
|
||||
var x1 = waypoint.X;
|
||||
var y1 = waypoint.Y;
|
||||
var x2 = position.X;
|
||||
var y2 = position.Y;
|
||||
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using System.Windows.Forms;
|
||||
using Vanara.PInvoke;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Linq;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using OpenCvSharp;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
public class PathExecutor
|
||||
{
|
||||
public static async Task Pathing(PathingTask task, CancellationTokenSource cts, bool withDelay = true)
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
SystemControl.ActivateWindow();
|
||||
|
||||
if (withDelay)
|
||||
{
|
||||
for (var i = 3; i >= 1; i--)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("{Sec}秒后开始寻路...", i);
|
||||
await Task.Delay(1000, cts.Token);
|
||||
}
|
||||
|
||||
TaskControl.Logger.LogInformation("开始寻路");
|
||||
}
|
||||
|
||||
if (task.Waypoints.Count == 0)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("没有路径点,寻路结束");
|
||||
return;
|
||||
}
|
||||
|
||||
if (task.Waypoints.First().WaypointType != WaypointType.Teleport)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("第一个路径点不是传送点,将不会进行传送");
|
||||
}
|
||||
|
||||
// 这里应该判断一下自动拾取是否处于工作状态,但好像没有什么方便的读取办法
|
||||
|
||||
// TODO:大地图传送的时候使用游戏坐标,追踪的时候应该使用2048地图图像坐标,这里临时做转换,后续改进
|
||||
foreach (var waypoint in task.Waypoints)
|
||||
{
|
||||
if (waypoint.WaypointType == WaypointType.Teleport)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(waypoint.X, waypoint.Y) = MapCoordinate.GameToMain2048(waypoint.X, waypoint.Y);
|
||||
}
|
||||
|
||||
foreach (var waypoint in task.Waypoints)
|
||||
{
|
||||
if (waypoint.WaypointType == WaypointType.Teleport)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("正在传送到{x},{y}", waypoint.X, waypoint.Y);
|
||||
await new TpTask(cts).Tp(waypoint.X, waypoint.Y);
|
||||
continue;
|
||||
}
|
||||
|
||||
// waypoint.WaypointType == WaypointType.Path 或者 WaypointType.Target
|
||||
// Path不用走得很近,Target需要接近,但都需要先移动到对应位置
|
||||
|
||||
await MoveTo(waypoint);
|
||||
|
||||
if (waypoint.WaypointType == WaypointType.Target)
|
||||
{
|
||||
await MoveCloseTo(waypoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static async Task MoveTo(Waypoint waypoint)
|
||||
{
|
||||
var position = await Task.Run(Navigation.GetPosition);
|
||||
var targetOrientation = Navigation.GetTargetOrientation(waypoint, Navigation.GetPosition());
|
||||
TaskControl.Logger.LogInformation("粗略接近路径点,当前位置({x1},{y1}),目标位置({x2},{y2})", position.X, position.Y, waypoint.X, waypoint.Y);
|
||||
await WaitUntilRotatedTo(targetOrientation, 10);
|
||||
var startTime = DateTime.UtcNow;
|
||||
var lastPositionRecord = DateTime.UtcNow;
|
||||
var fastMode = false;
|
||||
var prevPositions = new List<Point2f>();
|
||||
// 按下w,一直走
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
while (true)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if ((now - startTime).TotalSeconds > 30)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("执行超时,跳过路径点");
|
||||
break;
|
||||
}
|
||||
position = await Task.Run(Navigation.GetPosition);
|
||||
var distance = Navigation.GetDistance(waypoint, position);
|
||||
if (distance < 4)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("到达路径点附近");
|
||||
break;
|
||||
}
|
||||
if (distance > 500)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("距离过远,跳过路径点");
|
||||
break;
|
||||
}
|
||||
if ((now - lastPositionRecord).TotalMilliseconds > 1000)
|
||||
{
|
||||
lastPositionRecord = now;
|
||||
prevPositions.Add(position);
|
||||
if (prevPositions.Count > 8)
|
||||
{
|
||||
var delta = prevPositions[-1] - prevPositions[-8];
|
||||
if (Math.Abs(delta.X) + Math.Abs(delta.Y) < 3)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("疑似卡死,尝试脱离并跳过路径点");
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
await Task.Delay(500);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_S);
|
||||
await Task.Delay(500);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_A);
|
||||
await Task.Delay(500);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_D);
|
||||
await Task.Delay(500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 旋转视角
|
||||
targetOrientation = Navigation.GetTargetOrientation(waypoint, position);
|
||||
RotateTo(targetOrientation);
|
||||
// 根据指定方式进行移动
|
||||
if (waypoint.MoveType == MoveType.Fly)
|
||||
{
|
||||
// TODO:一直起跳直到打开风之翼
|
||||
if (!IsFlying())
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (IsFlying())
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Task.Delay(1000);
|
||||
continue;
|
||||
}
|
||||
if (waypoint.MoveType == MoveType.Jump)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
await Task.Delay(1000);
|
||||
continue;
|
||||
}
|
||||
// 跑步或者游泳
|
||||
if (distance > 20 != fastMode)// 距离大于20时可以使用疾跑/自由泳
|
||||
{
|
||||
if (fastMode)
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
}
|
||||
fastMode = !fastMode;
|
||||
}
|
||||
await Task.Delay(100);
|
||||
}
|
||||
// 抬起w键
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
|
||||
internal static async Task MoveCloseTo(Waypoint waypoint)
|
||||
{
|
||||
var position = await Task.Run(Navigation.GetPosition);
|
||||
var targetOrientation = Navigation.GetTargetOrientation(waypoint, Navigation.GetPosition());
|
||||
TaskControl.Logger.LogInformation("精确接近路径点,当前位置({x1},{y1}),目标位置({x2},{y2})", position.X, position.Y, waypoint.X, waypoint.Y);
|
||||
if (waypoint.MoveType == MoveType.Fly && IsFlying())
|
||||
{
|
||||
//下落攻击接近目的地
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
await WaitUntilRotatedTo(targetOrientation, 2);
|
||||
var wPressed = false;
|
||||
var stepsTaken = 0;
|
||||
while (true)
|
||||
{
|
||||
stepsTaken++;
|
||||
if (stepsTaken > 8)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("精确接近超时");
|
||||
break;
|
||||
}
|
||||
position = await Task.Run(Navigation.GetPosition);
|
||||
if (Navigation.GetDistance(waypoint, position) < 2)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("已到达路径点");
|
||||
break;
|
||||
}
|
||||
RotateTo(targetOrientation); //不再改变视角
|
||||
if (waypoint.MoveType == MoveType.Walk)
|
||||
{
|
||||
// 小碎步接近
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_W);
|
||||
await Task.Delay(500);
|
||||
continue;
|
||||
}
|
||||
if (!wPressed)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
if (wPressed)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
}
|
||||
|
||||
internal static int RotateTo(int targetOrientation)
|
||||
{
|
||||
var cao = CameraOrientation.Compute(TaskControl.CaptureToRectArea().SrcGreyMat);
|
||||
var diff = (cao - targetOrientation + 180) % 360 - 180;
|
||||
if (diff == 0)
|
||||
{
|
||||
return diff;
|
||||
}
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(30 * diff + 10 * diff > 0 ? 1 : -1, 0);
|
||||
return diff;
|
||||
}
|
||||
|
||||
internal static async Task WaitUntilRotatedTo(int targetOrientation, int maxDiff)
|
||||
{
|
||||
int count = 0;
|
||||
while (Math.Abs(RotateTo(targetOrientation)) > maxDiff && count < 50)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsFlying()
|
||||
{
|
||||
var greyMat = TaskControl.CaptureToRectArea().SrcGreyMat;
|
||||
greyMat = new Mat(greyMat, new Rect(1809, 1025, 61, 28));
|
||||
var text = OcrFactory.Paddle.OcrWithoutDetector(greyMat);
|
||||
return text.ToLower() == "space";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using System.IO;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
public class PathRecorder
|
||||
{
|
||||
public Model.PathingTask PathingTask { get; set; } = new Model.PathingTask();
|
||||
public void Start()
|
||||
{
|
||||
TaskControl.Logger.LogInformation("开始路径点记录");
|
||||
var waypoint = new Model.Waypoint();
|
||||
var position = Navigation.GetPosition();
|
||||
position = MapCoordinate.Main2048ToGame(position);
|
||||
waypoint.X = position.X;
|
||||
waypoint.Y = position.Y;
|
||||
waypoint.WaypointType = Model.WaypointType.Teleport;
|
||||
waypoint.MoveType = Model.MoveType.Walk;
|
||||
PathingTask.Waypoints.Add(waypoint);
|
||||
TaskControl.Logger.LogInformation("已创建初始路径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
}
|
||||
|
||||
public void AddWaypoint()
|
||||
{
|
||||
var waypoint = new Model.Waypoint();
|
||||
var position = Navigation.GetPosition();
|
||||
position = MapCoordinate.Main2048ToGame(position);
|
||||
waypoint.X = position.X;
|
||||
waypoint.Y = position.Y;
|
||||
waypoint.WaypointType = Model.WaypointType.Transit;
|
||||
waypoint.MoveType = Model.MoveType.Walk;
|
||||
PathingTask.Waypoints.Add(waypoint);
|
||||
TaskControl.Logger.LogInformation("已添加途径点({x},{y})", waypoint.X, waypoint.Y);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var json = JsonSerializer.Serialize(PathingTask);
|
||||
File.WriteAllText(Global.Absolute($@"log\way\{DateTime.Now:yyyy-MM-dd HH:mm:ss:ffff}.json"), json);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
PathingTask = new Model.PathingTask();
|
||||
}
|
||||
}
|
||||
@@ -323,38 +323,11 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取橙色选项的文字
|
||||
/// </summary>
|
||||
/// <param name="captureMat"></param>
|
||||
/// <param name="foundIconRectArea"></param>
|
||||
/// <param name="chatOptionTextWidth"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete]
|
||||
private string GetOrangeOptionText(Mat captureMat, ImageRegion foundIconRectArea, int chatOptionTextWidth)
|
||||
{
|
||||
var textRect = new Rect(foundIconRectArea.X + foundIconRectArea.Width, foundIconRectArea.Y, chatOptionTextWidth, foundIconRectArea.Height);
|
||||
using var mat = new Mat(captureMat, textRect);
|
||||
// 只提取橙色
|
||||
using var bMat = OpenCvCommonHelper.Threshold(mat, new Scalar(247, 198, 50), new Scalar(255, 204, 54));
|
||||
// Cv2.ImWrite("log/每日委托.png", bMat);
|
||||
var whiteCount = OpenCvCommonHelper.CountGrayMatColor(bMat, 255);
|
||||
var rate = whiteCount * 1.0 / (bMat.Width * bMat.Height);
|
||||
if (rate < 0.06)
|
||||
{
|
||||
Debug.WriteLine($"识别到橙色文字区域占比:{rate}");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var text = OcrFactory.Paddle.Ocr(bMat);
|
||||
return text;
|
||||
}
|
||||
|
||||
private bool IsOrangeOption(Mat textMat)
|
||||
{
|
||||
// 只提取橙色
|
||||
// Cv2.ImWrite($"log/text{DateTime.Now:yyyyMMddHHmmssffff}.png", textMat);
|
||||
using var bMat = OpenCvCommonHelper.Threshold(textMat, new Scalar(247, 198, 50), new Scalar(255, 204, 54));
|
||||
using var bMat = OpenCvCommonHelper.Threshold(textMat, new Scalar(243, 195, 48), new Scalar(255, 205, 55));
|
||||
var whiteCount = OpenCvCommonHelper.CountGrayMatColor(bMat, 255);
|
||||
var rate = whiteCount * 1.0 / (bMat.Width * bMat.Height);
|
||||
Debug.WriteLine($"识别到橙色文字区域占比:{rate}");
|
||||
@@ -613,6 +586,11 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
/// <param name="content"></param>
|
||||
private void ClosePopupPage(CaptureContent content)
|
||||
{
|
||||
if (!_config.ClosePopupPagedEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
content.CaptureRectArea.Find(_autoSkipAssets.PageCloseRo, pageCloseRoRa =>
|
||||
{
|
||||
TaskContext.Instance().PostMessageSimulator.KeyPress(User32.VK.VK_ESCAPE);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BigMap : Singleton<BigMap>
|
||||
{
|
||||
greyMat = ResizeHelper.Resize(greyMat, 1d / 4);
|
||||
|
||||
return _featureMatcher.MatchRect(greyMat);
|
||||
return _featureMatcher.KnnMatchRect(greyMat);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -16,21 +16,6 @@ public class EntireMap : Singleton<EntireMap>
|
||||
// 对无用部分进行裁剪(左160,上80,下96)
|
||||
public static readonly Rect TemplateSizeRoi = new(20, 10, TemplateSize.Width - 20, TemplateSize.Height - 22);
|
||||
|
||||
/// <summary>
|
||||
/// 主要地图缩小1024的模板
|
||||
/// </summary>
|
||||
// private readonly Mat _mainMap100BlockMat;
|
||||
|
||||
// /// <summary>
|
||||
// /// 1024区块拼接的主要地图
|
||||
// /// </summary>
|
||||
// private readonly Mat _mainMap1024BlockMat;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 2048城市区块拼接的主要地图
|
||||
// /// </summary>
|
||||
// private readonly Mat _cityMap2048BlockMat;
|
||||
|
||||
private readonly FeatureMatcher _featureMatcher;
|
||||
|
||||
private float _prevX = -1;
|
||||
@@ -38,39 +23,9 @@ public class EntireMap : Singleton<EntireMap>
|
||||
|
||||
public EntireMap()
|
||||
{
|
||||
// 大地图模板匹配使用的模板
|
||||
// _mainMap100BlockMat = MapAssets.Instance.MainMap100BlockMat.Value;
|
||||
// _mainMap1024BlockMat = MapAssets.Instance.MainMap1024BlockMat.Value;
|
||||
// _cityMap2048BlockMat = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\cityMap2048Block.png", ImreadModes.Grayscale);
|
||||
// Mat grey = new();
|
||||
// Cv2.CvtColor(_mainMap100BlockMat, grey, ColorConversionCodes.BGR2GRAY);
|
||||
// _featureMatcher = new FeatureMatcher(MapAssets.Instance.MainMap1024BlockMat.Value, new FeatureStorage("mainMap1024Block"));
|
||||
// 只从特征点加载
|
||||
_featureMatcher = new FeatureMatcher(new Size(28672, 26624), new FeatureStorage("mainMap2048Block"));
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 基于模板匹配获取地图位置(100区块,缩小了10.24倍)
|
||||
// /// 当前只支持大地图
|
||||
// /// </summary>
|
||||
// /// <param name="captureMat">彩色图像</param>
|
||||
// /// <returns></returns>
|
||||
// public Point GetMapPositionByMatchTemplate(Mat captureMat)
|
||||
// {
|
||||
// Cv2.CvtColor(captureMat, captureMat, ColorConversionCodes.BGRA2BGR);
|
||||
// using var tar = new Mat(captureMat.Resize(TemplateSize, 0, 0, InterpolationFlags.Cubic), TemplateSizeRoi);
|
||||
// var p = MatchTemplateHelper.MatchTemplate(_mainMap100BlockMat, tar, TemplateMatchModes.CCoeffNormed, null, 0.2);
|
||||
// Debug.WriteLine($"BigMap Match Template: {p}");
|
||||
// return p;
|
||||
// }
|
||||
//
|
||||
// public void GetMapPositionAndDrawByMatchTemplate(Mat captureMat)
|
||||
// {
|
||||
// var p = GetMapPositionByMatchTemplate(captureMat);
|
||||
// WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<object>(this, "UpdateBigMapRect", new object(),
|
||||
// new System.Windows.Rect(p.X, p.Y, TemplateSizeRoi.Width, TemplateSizeRoi.Height)));
|
||||
// }
|
||||
|
||||
private int _failCnt = 0;
|
||||
|
||||
/// <summary>
|
||||
@@ -87,11 +42,11 @@ public class EntireMap : Singleton<EntireMap>
|
||||
Point2f p;
|
||||
if (_prevX <= 0 && _prevY <= 0)
|
||||
{
|
||||
p = _featureMatcher.Match(greyMat, _prevX, _prevY, mask);
|
||||
p = _featureMatcher.KnnMatch(greyMat, mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = _featureMatcher.Match(greyMat, mask);
|
||||
p = _featureMatcher.KnnMatch(greyMat, _prevX, _prevY, mask, DescriptorMatcherType.BruteForce);
|
||||
}
|
||||
|
||||
if (p.IsEmpty())
|
||||
@@ -139,35 +94,4 @@ public class EntireMap : Singleton<EntireMap>
|
||||
return new Point2f();
|
||||
}
|
||||
}
|
||||
|
||||
// public static Point GetIntersection(Point2f[] points)
|
||||
// {
|
||||
// double a1 = (points[0].Y - points[2].Y) / (double)(points[0].X - points[2].X);
|
||||
// double b1 = points[0].Y - a1 * points[0].X;
|
||||
//
|
||||
// double a2 = (points[1].Y - points[3].Y) / (double)(points[1].X - points[3].X);
|
||||
// double b2 = points[1].Y - a2 * points[1].X;
|
||||
//
|
||||
// if (Math.Abs(a1 - a2) < double.Epsilon)
|
||||
// {
|
||||
// // 不相交
|
||||
// throw new InvalidOperationException();
|
||||
// }
|
||||
//
|
||||
// double x = (b2 - b1) / (a1 - a2);
|
||||
// double y = a1 * x + b1;
|
||||
// return new Point((int)x, (int)y);
|
||||
// }
|
||||
|
||||
// public void GetMapPositionAndDrawByFeatureMatch(Mat captureGreyMat)
|
||||
// {
|
||||
// var rect = GetMiniMapPositionByFeatureMatch(captureGreyMat);
|
||||
// if (rect != Rect.Empty)
|
||||
// {
|
||||
// WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<object>(this, "UpdateBigMapRect", new object(),
|
||||
// new System.Windows.Rect(rect.X / 20.48, rect.Y / 20.48, rect.Width / 20.48, rect.Height / 20.48)));
|
||||
// // WeakReferenceMessenger.Default.Send(new PropertyChangedMessage<object>(this, "UpdateBigMapRect", new object(),
|
||||
// // new System.Windows.Rect(rect.X / 10.24, rect.Y / 10.24, rect.Width / 10.24, rect.Height / 10.24)));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -9,4 +9,5 @@ public enum IndependentTaskEnum
|
||||
AutoTrack,
|
||||
AutoTrackPath,
|
||||
AutoMusicGame,
|
||||
AutoPathing,
|
||||
}
|
||||
@@ -135,11 +135,11 @@ internal static class RuntimeHelper
|
||||
|
||||
public static void CheckIntegration()
|
||||
{
|
||||
if (!Directory.Exists("Assets") || !Directory.Exists("GameTask") || !Directory.Exists("User"))
|
||||
if (!Directory.Exists(Global.Absolute("Assets")) || !Directory.Exists(Global.Absolute("GameTask")))
|
||||
{
|
||||
StringBuilder stringBuilder = new("发现有关键文件缺失,");
|
||||
stringBuilder.Append(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) == Global.StartUpPath
|
||||
? "请不要把主程序exe文件剪切到桌面"
|
||||
? "请不要把主程序exe文件剪切到桌面。正确的做法:请右键点击主程序,在弹出的菜单中选择“发送到”选项,然后选择“桌面创建快捷方式”。"
|
||||
: "请重新安装软件");
|
||||
|
||||
MessageBox.Show(stringBuilder.ToString(),
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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 it is too large.
Load diff
@@ -1 +0,0 @@
|
||||
{"macroEvents":[{"type":3,"mouseX":3,"mouseY":1,"time":1421.0958},{"type":3,"mouseX":5,"mouseY":0,"time":1443.9352},{"type":3,"mouseX":13,"mouseY":1,"time":1466.6229},{"type":3,"mouseX":26,"mouseY":-3,"time":1490.0079},{"type":0,"keyCode":87,"mouseX":0,"mouseY":0,"time":1504.6397},{"type":3,"mouseX":22,"mouseY":-4,"time":1511.9668},{"type":3,"mouseX":18,"mouseY":-3,"time":1534.6937},{"type":3,"mouseX":21,"mouseY":-1,"time":1561.3198},{"type":3,"mouseX":32,"mouseY":-1,"time":1584.4359},{"type":3,"mouseX":26,"mouseY":2,"time":1606.3658},{"type":3,"mouseX":34,"mouseY":4,"time":1629.0205},{"type":3,"mouseX":19,"mouseY":2,"time":1656.9458},{"type":3,"mouseX":22,"mouseY":5,"time":1680.5213},{"type":3,"mouseX":23,"mouseY":5,"time":1702.8503},{"type":3,"mouseX":34,"mouseY":6,"time":1725.5975},{"type":3,"mouseX":33,"mouseY":4,"time":1753.4622},{"type":3,"mouseX":28,"mouseY":3,"time":1776.1994},{"type":3,"mouseX":21,"mouseY":3,"time":1798.7822},{"type":3,"mouseX":25,"mouseY":3,"time":1821.0148},{"type":3,"mouseX":27,"mouseY":3,"time":1848.8726},{"type":3,"mouseX":34,"mouseY":3,"time":1871.9005},{"type":3,"mouseX":31,"mouseY":2,"time":1894.9154},{"type":3,"mouseX":30,"mouseY":4,"time":1922.8236},{"type":3,"mouseX":35,"mouseY":5,"time":1945.3775},{"type":3,"mouseX":40,"mouseY":5,"time":1968.2997},{"type":3,"mouseX":42,"mouseY":4,"time":1991.725},{"type":3,"mouseX":43,"mouseY":5,"time":2014.5422},{"type":3,"mouseX":63,"mouseY":9,"time":2037.3526},{"type":3,"mouseX":68,"mouseY":8,"time":2065.0827},{"type":3,"mouseX":68,"mouseY":8,"time":2088.6154},{"type":3,"mouseX":48,"mouseY":5,"time":2112.2058},{"type":3,"mouseX":46,"mouseY":6,"time":2136.363},{"type":3,"mouseX":40,"mouseY":7,"time":2158.8514},{"type":3,"mouseX":29,"mouseY":4,"time":2187.0039},{"type":3,"mouseX":28,"mouseY":4,"time":2209.4479},{"type":3,"mouseX":23,"mouseY":4,"time":2233.1082},{"type":3,"mouseX":18,"mouseY":4,"time":2257.3163},{"type":3,"mouseX":24,"mouseY":5,"time":2279.1083},{"type":3,"mouseX":20,"mouseY":2,"time":2301.7491},{"type":3,"mouseX":15,"mouseY":2,"time":2329.4706},{"type":3,"mouseX":11,"mouseY":2,"time":2351.846},{"type":3,"mouseX":16,"mouseY":4,"time":2379.3702},{"type":3,"mouseX":18,"mouseY":4,"time":2401.9279},{"type":3,"mouseX":40,"mouseY":7,"time":2425.4059},{"type":3,"mouseX":31,"mouseY":2,"time":2447.3603},{"type":3,"mouseX":59,"mouseY":9,"time":2471.0853},{"type":3,"mouseX":57,"mouseY":6,"time":2498.437},{"type":3,"mouseX":55,"mouseY":3,"time":2520.838},{"type":3,"mouseX":17,"mouseY":0,"time":2544.0637},{"type":3,"mouseX":15,"mouseY":2,"time":2566.3104},{"type":3,"mouseX":24,"mouseY":5,"time":2594.1411},{"type":3,"mouseX":27,"mouseY":4,"time":2616.6343},{"type":3,"mouseX":13,"mouseY":2,"time":2640.0805},{"type":3,"mouseX":16,"mouseY":2,"time":2662.8098},{"type":3,"mouseX":8,"mouseY":2,"time":2690.3809},{"type":3,"mouseX":6,"mouseY":2,"time":2712.9887},{"type":3,"mouseX":17,"mouseY":3,"time":2735.185},{"type":3,"mouseX":25,"mouseY":2,"time":2769.04},{"type":3,"mouseX":23,"mouseY":3,"time":2792.986},{"type":3,"mouseX":21,"mouseY":3,"time":2816.3568},{"type":3,"mouseX":66,"mouseY":8,"time":2838.5657},{"type":3,"mouseX":45,"mouseY":11,"time":2867.3428},{"type":3,"mouseX":21,"mouseY":10,"time":2895.7916},{"type":3,"mouseX":45,"mouseY":22,"time":2918.171},{"type":3,"mouseX":71,"mouseY":23,"time":2940.2312},{"type":3,"mouseX":51,"mouseY":11,"time":2963.0335},{"type":3,"mouseX":17,"mouseY":3,"time":2991.3917},{"type":3,"mouseX":3,"mouseY":1,"time":3066.2524},{"type":3,"mouseX":-8,"mouseY":4,"time":3111.7298},{"type":3,"mouseX":-14,"mouseY":6,"time":3133.6521},{"type":3,"mouseX":-14,"mouseY":6,"time":3157.3638},{"type":3,"mouseX":-16,"mouseY":13,"time":3179.4674},{"type":3,"mouseX":-8,"mouseY":13,"time":3207.0986},{"type":3,"mouseX":-2,"mouseY":3,"time":3235.8785},{"type":3,"mouseX":0,"mouseY":2,"time":3264.2571},{"type":0,"keyCode":32,"mouseX":0,"mouseY":0,"time":3279.856},{"type":3,"mouseX":1,"mouseY":3,"time":3280.5546},{"type":3,"mouseX":6,"mouseY":9,"time":3307.5749},{"type":3,"mouseX":10,"mouseY":16,"time":3329.3775},{"type":3,"mouseX":14,"mouseY":17,"time":3353.2007},{"type":3,"mouseX":11,"mouseY":14,"time":3374.9806},{"type":3,"mouseX":10,"mouseY":17,"time":3402.8405},{"type":3,"mouseX":9,"mouseY":15,"time":3426.0493},{"type":3,"mouseX":10,"mouseY":10,"time":3448.7478},{"type":3,"mouseX":12,"mouseY":10,"time":3471.5988},{"type":3,"mouseX":4,"mouseY":4,"time":3499.4246},{"type":3,"mouseX":1,"mouseY":1,"time":3571.6011},{"type":1,"keyCode":32,"mouseX":0,"mouseY":0,"time":3576.1956},{"type":3,"mouseX":0,"mouseY":1,"time":3582.4667},{"type":3,"mouseX":6,"mouseY":7,"time":3626.8481},{"type":3,"mouseX":20,"mouseY":15,"time":3655.4021},{"type":3,"mouseX":25,"mouseY":9,"time":3684.2742},{"type":3,"mouseX":41,"mouseY":8,"time":3707.1353},{"type":3,"mouseX":58,"mouseY":4,"time":3734.065},{"type":3,"mouseX":81,"mouseY":4,"time":3756.3257},{"type":3,"mouseX":89,"mouseY":2,"time":3778.3074},{"type":3,"mouseX":54,"mouseY":-2,"time":3805.1383},{Line truncated
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
* 注意本脚本的方案是首次传送到晶蝶位置后的方案。
|
||||
* 如果你在传送点待了很久的话,晶蝶会自己飞走,即便是有早柚的情况下。
|
||||
* 这种情况下没法完全捕捉到晶蝶。
|
||||
*
|
||||
* 有些点位未探索可能会导致没有晶蝶,请自行探索。
|
||||
*/
|
||||
(async function () {
|
||||
|
||||
@@ -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);
|
||||
})();
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"id": "bgi_crystalfly",
|
||||
"name": "自动采集晶蝶",
|
||||
"name": "自动采集晶蝶(枫丹)",
|
||||
"version": "1.0",
|
||||
"description": "BetterGI自带脚本,自动采集离传送点较近的晶蝶。",
|
||||
"authors": [
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.Service.Interface;
|
||||
|
||||
public interface IScriptService
|
||||
{
|
||||
Task RunMulti(List<string> folderNameList, string? groupName = null);
|
||||
|
||||
Task RunMulti(IEnumerable<ScriptGroupProject> projectList, string groupName);
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
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;
|
||||
|
||||
public partial class ScriptService(HomePageViewModel homePageViewModel) : IScriptService
|
||||
{
|
||||
private readonly ILogger<ScriptService> _logger = App.GetLogger<ScriptService>();
|
||||
|
||||
public async Task RunMulti(List<string> folderNameList, string? groupName = null)
|
||||
{
|
||||
// 重新加载脚本项目
|
||||
var projects = folderNameList.Select(name => new ScriptProject(name)).ToList();
|
||||
|
||||
var codeList = await ReadCodeList(projects);
|
||||
var hasTimer = HasTimerOperation(codeList);
|
||||
|
||||
// 没启动时候,启动截图器
|
||||
await homePageViewModel.OnStartTriggerAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
if (hasTimer)
|
||||
{
|
||||
_logger.LogInformation("配置组 {Name} 包含实时任务操作调用", groupName);
|
||||
}
|
||||
|
||||
_logger.LogInformation("配置组 {Name} 加载完成,共{Cnt}个脚本,开始执行", groupName, projects.Count);
|
||||
}
|
||||
|
||||
// 循环执行所有脚本
|
||||
var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;
|
||||
await new TaskRunner(timerOperation)
|
||||
.RunAsync(async () =>
|
||||
{
|
||||
foreach (var project in projects)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hasTimer)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
}
|
||||
|
||||
_logger.LogInformation("------------------------------");
|
||||
_logger.LogInformation("→ 开始执行脚本: {Name}", project.Manifest.Name);
|
||||
await project.ExecuteAsync();
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "执行脚本时发生异常");
|
||||
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_logger.LogInformation("→ 脚本执行结束: {Name}", project.Manifest.Name);
|
||||
_logger.LogInformation("------------------------------");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
_logger.LogInformation("配置组 {Name} 执行结束", groupName);
|
||||
}
|
||||
}
|
||||
|
||||
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>();
|
||||
foreach (var project in list)
|
||||
{
|
||||
var code = await project.LoadCode();
|
||||
codeList.Add(code);
|
||||
}
|
||||
|
||||
return codeList;
|
||||
}
|
||||
|
||||
private bool HasTimerOperation(IEnumerable<string> codeList)
|
||||
{
|
||||
return codeList.Any(code => DispatcherAddTimerRegex().IsMatch(code));
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^(?!\s*\/\/)\s*dispatcher\.\s*addTimer", RegexOptions.Multiline)]
|
||||
private static partial Regex DispatcherAddTimerRegex();
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
Grid.Row="1"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
IsPaneToggleVisible="True"
|
||||
OpenPaneLength="150">
|
||||
OpenPaneLength="160">
|
||||
<ui:NavigationView.MenuItems>
|
||||
<ui:NavigationViewItem Content="启动"
|
||||
NavigationCacheMode="Enabled"
|
||||
@@ -77,28 +77,49 @@
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<!--<ui:NavigationViewItemSeparator />-->
|
||||
<!--<ui:NavigationViewItem Content="调度器"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:DispatcherPage}">
|
||||
|
||||
<ui:NavigationViewItem Content="全自动">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Bot24" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>-->
|
||||
<!-- WebAsset24 | DocumentJs16 -->
|
||||
<ui:NavigationViewItem Content="脚本管理"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:ScriptControlPage}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Script16" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<!-- Script16 -->
|
||||
<ui:NavigationViewItem Content="录制回放"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:KeyMouseRecordPage}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Record24" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
<ui:NavigationViewItem.MenuItems>
|
||||
|
||||
<!--<ui:NavigationViewItemSeparator />-->
|
||||
<!-- ConvertRange20 -->
|
||||
<ui:NavigationViewItem Content="调度器"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:ScriptControlPage}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="DeveloperBoard24" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<!-- WebAsset24 | DocumentJs16 | Script16 -->
|
||||
<ui:NavigationViewItem Content="脚本"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:JsListPage}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="DocumentJs16" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<!-- Map24 -->
|
||||
<ui:NavigationViewItem Content="地图追踪"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:ScriptControlPage}"
|
||||
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Map24" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
<!-- Script16 -->
|
||||
<ui:NavigationViewItem Content="录制回放"
|
||||
NavigationCacheMode="Enabled"
|
||||
TargetPageType="{x:Type pages:KeyMouseRecordPage}">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:SymbolIcon Symbol="Record24" />
|
||||
</ui:NavigationViewItem.Icon>
|
||||
</ui:NavigationViewItem>
|
||||
</ui:NavigationViewItem.MenuItems>
|
||||
</ui:NavigationViewItem>
|
||||
|
||||
<ui:NavigationViewItem Content="快捷键"
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<Page x:Class="BetterGenshinImpact.View.Pages.JsListPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:BetterGenshinImpact.View.Pages"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
Title="JsListPage"
|
||||
d:DataContext="{d:DesignInstance Type=pages:JsListViewModel}"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="800"
|
||||
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
|
||||
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
FontFamily="{StaticResource TextThemeFontFamily}"
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/View/Controls/Style/ListViewEx.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
<Grid Margin="42,16,42,12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="400" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Margin="0,0,0,8"
|
||||
FontTypography="BodyStrong"
|
||||
Text="自定义 Javascript 脚本(开发中功能)" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Margin="0,0,0,8"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="可以通过 Javascript 调用 BetterGI 在原神中的各项能力,右键可以直接执行脚本"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<ui:Button Command="{Binding OpenScriptsFolderCommand}"
|
||||
Content="打开脚本目录"
|
||||
Icon="{ui:SymbolIcon FolderOpen24}" />
|
||||
</StackPanel>
|
||||
|
||||
<Separator Grid.Row="3"
|
||||
Height="10"
|
||||
Opacity="0" />
|
||||
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<!-- <ColumnDefinition Width="120" /> -->
|
||||
<ColumnDefinition Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid x:Name="Col1" Grid.Column="0" />
|
||||
<Grid x:Name="Col2" Grid.Column="1" />
|
||||
<Grid x:Name="Col3" Grid.Column="2" />
|
||||
<Grid x:Name="Col4" Grid.Column="3" />
|
||||
<!-- <Grid x:Name="Col5" Grid.Column="4" /> -->
|
||||
</Grid>
|
||||
<ui:ListView Grid.Row="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ItemsSource="{Binding ScriptItems}"
|
||||
SelectionMode="Single">
|
||||
<ListView.View>
|
||||
<GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderDarkStyle}">
|
||||
<GridViewColumn Width="{Binding ElementName=Col1, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding FolderName}"
|
||||
Header="目录" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col2, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding Manifest.Name}"
|
||||
Header="名称" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col3, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding Manifest.Version}"
|
||||
Header="版本" />
|
||||
<!--<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}" Header="操作">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:JsListPage}}, Path=DataContext.StartRunCommand}"
|
||||
CommandParameter="{Binding ProjectPath}"
|
||||
Content="执行脚本"
|
||||
Icon="{ui:SymbolIcon Play24}" />
|
||||
</StackPanel>
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>-->
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="{Binding OpenScriptProjectFolderCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="打开目录" />
|
||||
<MenuItem Command="{Binding StartRunCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
||||
Header="执行脚本" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListView.Style>
|
||||
<Style TargetType="{x:Type ListView}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
</ListView.Style>
|
||||
</ui:ListView>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,19 @@
|
||||
using BetterGenshinImpact.ViewModel;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.View.Pages;
|
||||
|
||||
/// <summary>
|
||||
/// JsListPage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class JsListPage : Page
|
||||
{
|
||||
private JsListViewModel ViewModel { get; }
|
||||
|
||||
public JsListPage(JsListViewModel viewModel)
|
||||
{
|
||||
DataContext = ViewModel = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -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}"
|
||||
@@ -104,6 +104,9 @@
|
||||
</ListView.View>
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="{Binding EditScriptCommand}"
|
||||
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="删除" />
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
BorderThickness="0,0,0,1">
|
||||
<ui:TextBlock Margin="4,4,8,4"
|
||||
FontTypography="BodyStrong"
|
||||
Text="脚本组"
|
||||
Text="配置组"
|
||||
TextAlignment="Center" />
|
||||
</Border>
|
||||
<ui:ListView Grid.Row="1"
|
||||
@@ -96,25 +96,25 @@
|
||||
<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>
|
||||
<!-- 示例脚本组 -->
|
||||
<!-- 示例配置组 -->
|
||||
<ui:TextBlock Margin="0,0,0,8"
|
||||
FontTypography="BodyStrong"
|
||||
Text="也可以直接点击导入下面的示例脚本组" />
|
||||
Text="也可以直接点击导入下面的示例配置组" />
|
||||
<ui:TextBlock Margin="0,0,0,8"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap">
|
||||
<Hyperlink Command="{Binding ImportScriptGroupCommand}"
|
||||
CommandParameter="AutoCrystalflyExampleGroup"
|
||||
Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
|
||||
导入自动晶蝶示例脚本组
|
||||
导入自动晶蝶示例配置组
|
||||
</Hyperlink>
|
||||
</ui:TextBlock>
|
||||
</StackPanel>
|
||||
@@ -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"
|
||||
@@ -191,7 +187,9 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
@@ -199,6 +197,8 @@
|
||||
<Grid x:Name="Col2" Grid.Column="1" />
|
||||
<Grid x:Name="Col3" Grid.Column="2" />
|
||||
<Grid x:Name="Col4" Grid.Column="3" />
|
||||
<Grid x:Name="Col5" Grid.Column="4" />
|
||||
<Grid x:Name="Col6" Grid.Column="5" />
|
||||
</Grid>
|
||||
<ui:ListView Grid.Row="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
@@ -214,21 +214,31 @@
|
||||
Header="#" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col2, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Header="脚本名称" />
|
||||
Header="名称" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col3, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding TypeDesc}"
|
||||
Header="类型" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding ScheduleDesc}"
|
||||
Header="执行周期" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col4, Path=ActualWidth}"
|
||||
<GridViewColumn Width="{Binding ElementName=Col5, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding RunNum}"
|
||||
Header="执行次数" />
|
||||
<GridViewColumn Width="{Binding ElementName=Col6, Path=ActualWidth}"
|
||||
DisplayMemberBinding="{Binding StatusDesc}"
|
||||
Header="启用状态" />
|
||||
</GridView>
|
||||
</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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.GameTask.Macro;
|
||||
@@ -128,6 +129,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),
|
||||
@@ -367,17 +379,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(
|
||||
@@ -434,6 +435,57 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
User32.SetWindowPos(TaskContext.Instance().GameHandle, new HWND(), 0, 0, 1920, 1080, SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOZORDER);
|
||||
}
|
||||
));
|
||||
|
||||
var _pathRecorder = new PathRecorder();
|
||||
var _pathRecording = false;
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)路径记录器",
|
||||
nameof(Config.HotKeyConfig.PathRecorderHotkey),
|
||||
Config.HotKeyConfig.PathRecorderHotkey,
|
||||
Config.HotKeyConfig.PathRecorderHotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
if (_pathRecording)
|
||||
{
|
||||
_pathRecorder.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
_pathRecorder.Clear();
|
||||
_pathRecorder.Start();
|
||||
}
|
||||
_pathRecording = !_pathRecording;
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)添加记录点",
|
||||
nameof(Config.HotKeyConfig.AddWaypointHotkey),
|
||||
Config.HotKeyConfig.AddWaypointHotkey,
|
||||
Config.HotKeyConfig.AddWaypointHotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
if (_pathRecording)
|
||||
{
|
||||
_pathRecorder.AddWaypoint();
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
HotKeySettingModels.Add(new HotKeySettingModel(
|
||||
"(测试)播放内存中的路径",
|
||||
nameof(Config.HotKeyConfig.ExecutePathHotkey),
|
||||
Config.HotKeyConfig.ExecutePathHotkey,
|
||||
Config.HotKeyConfig.ExecutePathHotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
if (_pathRecording)
|
||||
{
|
||||
PathExecutor.Pathing(_pathRecorder.PathingTask, new CancellationTokenSource());
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Model;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
using static Vanara.PInvoke.Gdi32;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.Service;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
public partial class JsListViewModel : ObservableObject, INavigationAware, IViewModel
|
||||
{
|
||||
private readonly ILogger<JsListViewModel> _logger = App.GetLogger<JsListViewModel>();
|
||||
private readonly string scriptPath = Global.Absolute("Script");
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ScriptProject> _scriptItems = [];
|
||||
|
||||
private ISnackbarService _snackbarService;
|
||||
private IScriptService _scriptService;
|
||||
|
||||
public JsListViewModel(ISnackbarService snackbarService, IScriptService scriptService)
|
||||
{
|
||||
_snackbarService = snackbarService;
|
||||
_scriptService = scriptService;
|
||||
}
|
||||
|
||||
private void InitScriptListViewData()
|
||||
{
|
||||
_scriptItems.Clear();
|
||||
var directoryInfos = LoadScriptFolder(scriptPath);
|
||||
foreach (var f in directoryInfos)
|
||||
{
|
||||
try
|
||||
{
|
||||
_scriptItems.Add(new ScriptProject(f.Name));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Toast.Warning($"脚本 {f.Name} 载入失败:{e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<DirectoryInfo> LoadScriptFolder(string folder)
|
||||
{
|
||||
if (!Directory.Exists(folder))
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
var di = new DirectoryInfo(folder);
|
||||
|
||||
return di.GetDirectories();
|
||||
}
|
||||
|
||||
public void OnNavigatedTo()
|
||||
{
|
||||
InitScriptListViewData();
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom()
|
||||
{
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnOpenScriptsFolder()
|
||||
{
|
||||
Process.Start("explorer.exe", scriptPath);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnOpenScriptProjectFolder(ScriptProject? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Process.Start("explorer.exe", item.ProjectPath);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task OnStartRun(ScriptProject? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await _scriptService.RunMulti([item.FolderName]);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -16,7 +17,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -82,7 +83,7 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
MessageBox.Show("请先在启动页,启动截图器再使用本功能");
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
if (!IsRecording)
|
||||
@@ -141,6 +142,50 @@ public partial class KeyMouseRecordPageViewModel : ObservableObject, INavigation
|
||||
Process.Start("explorer.exe", scriptPath);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnEditScript(KeyMouseScriptItem? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var str = PromptDialog.Prompt("请输入要修改为的名称(实际就是文件名)", "修改名称");
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
// 检查原始文件是否存在
|
||||
var originalFilePath = Path.Combine(scriptPath, item.Name);
|
||||
if (File.Exists(originalFilePath))
|
||||
{
|
||||
// 重命名文件
|
||||
File.Move(originalFilePath, Path.Combine(scriptPath, str + ".json"));
|
||||
_snackbarService.Show(
|
||||
"修改名称成功",
|
||||
$"脚本名称 {item.Name} 修改为 {str}",
|
||||
ControlAppearance.Success,
|
||||
null,
|
||||
TimeSpan.FromSeconds(2)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_snackbarService.Show(
|
||||
"修改失败",
|
||||
$"{item.Name} 修改失败",
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
TimeSpan.FromSeconds(3)
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
InitScriptListViewData();
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void OnDeleteScript(KeyMouseScriptItem? item)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
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;
|
||||
@@ -14,7 +15,6 @@ using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using Wpf.Ui;
|
||||
@@ -30,14 +30,16 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
|
||||
private readonly HomePageViewModel _homePageViewModel;
|
||||
|
||||
private readonly IScriptService _scriptService;
|
||||
|
||||
/// <summary>
|
||||
/// 脚本组配置
|
||||
/// 配置组配置
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ScriptGroup> _scriptGroups = [];
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的脚本组
|
||||
/// 当前选中的配置组
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ScriptGroup? _selectedScriptGroup;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -63,15 +66,15 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
[RelayCommand]
|
||||
private void OnAddScriptGroup()
|
||||
{
|
||||
var str = PromptDialog.Prompt("请输入脚本组名称", "新增脚本组");
|
||||
var str = PromptDialog.Prompt("请输入配置组名称", "新增配置组");
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
// 检查是否已存在
|
||||
if (ScriptGroups.Any(x => x.Name == str))
|
||||
{
|
||||
_snackbarService.Show(
|
||||
"脚本组已存在",
|
||||
$"脚本组 {str} 已经存在,请勿重复添加",
|
||||
"配置组已存在",
|
||||
$"配置组 {str} 已经存在,请勿重复添加",
|
||||
ControlAppearance.Caution,
|
||||
null,
|
||||
TimeSpan.FromSeconds(2)
|
||||
@@ -97,8 +100,8 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
ScriptGroups.Remove(item);
|
||||
File.Delete(Path.Combine(ScriptGroupPath, $"{item.Name}.json"));
|
||||
_snackbarService.Show(
|
||||
"脚本组删除成功",
|
||||
$"脚本组 {item.Name} 已经被删除",
|
||||
"配置组删除成功",
|
||||
$"配置组 {item.Name} 已经被删除",
|
||||
ControlAppearance.Success,
|
||||
null,
|
||||
TimeSpan.FromSeconds(2)
|
||||
@@ -106,10 +109,10 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "删除脚本组配置时失败");
|
||||
_logger.LogDebug(e, "删除配置组配置时失败");
|
||||
_snackbarService.Show(
|
||||
"删除脚本组配置失败",
|
||||
$"脚本组 {item.Name} 删除失败!",
|
||||
"删除配置组配置失败",
|
||||
$"配置组 {item.Name} 删除失败!",
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
TimeSpan.FromSeconds(3)
|
||||
@@ -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)
|
||||
{
|
||||
@@ -189,7 +247,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
group.Index = i++;
|
||||
}
|
||||
|
||||
// 保存脚本组配置
|
||||
// 保存配置组配置
|
||||
foreach (var group in ScriptGroups)
|
||||
{
|
||||
WriteScriptGroup(group);
|
||||
@@ -208,7 +266,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
}
|
||||
|
||||
// 保存脚本组配置
|
||||
// 保存配置组配置
|
||||
if (SelectedScriptGroup != null)
|
||||
{
|
||||
WriteScriptGroup(SelectedScriptGroup);
|
||||
@@ -229,9 +287,9 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "保存脚本组配置时失败");
|
||||
_logger.LogDebug(e, "保存配置组配置时失败");
|
||||
_snackbarService.Show(
|
||||
"保存脚本组配置失败",
|
||||
"保存配置组配置失败",
|
||||
$"{scriptGroup.Name} 保存失败!",
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
@@ -262,10 +320,10 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "读取单个脚本组配置时失败");
|
||||
_logger.LogDebug(e, "读取单个配置组配置时失败");
|
||||
_snackbarService.Show(
|
||||
"读取脚本组配置失败",
|
||||
"读取脚本组配置失败:" + e.Message,
|
||||
"读取配置组配置失败",
|
||||
"读取配置组配置失败:" + e.Message,
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
TimeSpan.FromSeconds(3)
|
||||
@@ -282,10 +340,10 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "读取脚本组配置时失败");
|
||||
_logger.LogDebug(e, "读取配置组配置时失败");
|
||||
_snackbarService.Show(
|
||||
"读取脚本组配置失败",
|
||||
"读取脚本组配置失败!",
|
||||
"读取配置组配置失败",
|
||||
"读取配置组配置失败!",
|
||||
ControlAppearance.Danger,
|
||||
null,
|
||||
TimeSpan.FromSeconds(3)
|
||||
@@ -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)
|
||||
{
|
||||
@@ -318,8 +370,8 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
if (ScriptGroups.Any(x => x.Name == group.Name))
|
||||
{
|
||||
_snackbarService.Show(
|
||||
"脚本组已存在",
|
||||
$"脚本组 {group.Name} 已经存在,请勿重复添加",
|
||||
"配置组已存在",
|
||||
$"配置组 {group.Name} 已经存在,请勿重复添加",
|
||||
ControlAppearance.Caution,
|
||||
null,
|
||||
TimeSpan.FromSeconds(2)
|
||||
@@ -336,8 +388,8 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
if (SelectedScriptGroup == null)
|
||||
{
|
||||
_snackbarService.Show(
|
||||
"未选择脚本组",
|
||||
"请先选择一个脚本组",
|
||||
"未选择配置组",
|
||||
"请先选择一个配置组",
|
||||
ControlAppearance.Caution,
|
||||
null,
|
||||
TimeSpan.FromSeconds(2)
|
||||
@@ -345,72 +397,6 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
return;
|
||||
}
|
||||
|
||||
// 没启动时候,启动截图器
|
||||
await _homePageViewModel.OnStartTriggerAsync();
|
||||
|
||||
// 重新加载脚本项目
|
||||
var projects = SelectedScriptGroup.Projects.Select(project => new ScriptProject(project.FolderName)).ToList();
|
||||
|
||||
var codeList = await ReadCodeList(projects);
|
||||
var hasTimer = HasTimerOperation(codeList);
|
||||
if (hasTimer)
|
||||
{
|
||||
_logger.LogInformation("脚本组 {Name} 包含实时任务操作调用", SelectedScriptGroup.Name);
|
||||
}
|
||||
|
||||
_logger.LogInformation("脚本组 {Name} 加载完成,共{Cnt}个脚本,开始执行", SelectedScriptGroup.Name, projects.Count);
|
||||
|
||||
// 循环执行所有脚本
|
||||
var timerOperation = hasTimer ? DispatcherTimerOperationEnum.UseCacheImageWithTriggerEmpty : DispatcherTimerOperationEnum.UseSelfCaptureImage;
|
||||
await new TaskRunner(timerOperation)
|
||||
.RunAsync(async () =>
|
||||
{
|
||||
foreach (var project in projects)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hasTimer)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
}
|
||||
|
||||
_logger.LogInformation("------------------------------");
|
||||
_logger.LogInformation("→ 开始执行脚本: {Name}", project.Manifest.Name);
|
||||
await project.ExecuteAsync();
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, "执行脚本时发生异常");
|
||||
_logger.LogError("执行脚本时发生异常: {Msg}", e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_logger.LogInformation("→ 脚本执行结束: {Name}", project.Manifest.Name);
|
||||
_logger.LogInformation("------------------------------");
|
||||
}
|
||||
}
|
||||
});
|
||||
_logger.LogInformation("脚本组 {Name} 执行结束", SelectedScriptGroup.Name);
|
||||
await _scriptService.RunMulti(SelectedScriptGroup.Projects, SelectedScriptGroup.Name);
|
||||
}
|
||||
|
||||
private async Task<List<string>> ReadCodeList(List<ScriptProject> list)
|
||||
{
|
||||
var codeList = new List<string>();
|
||||
foreach (var project in list)
|
||||
{
|
||||
var code = await project.LoadCode();
|
||||
codeList.Add(code);
|
||||
}
|
||||
|
||||
return codeList;
|
||||
}
|
||||
|
||||
private bool HasTimerOperation(IEnumerable<string> codeList)
|
||||
{
|
||||
return codeList.Any(code => DispatcherAddTimerRegex().IsMatch(code));
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^(?!\s*\/\/)\s*dispatcher\.\s*addTimer", RegexOptions.Multiline)]
|
||||
private static partial Regex DispatcherAddTimerRegex();
|
||||
}
|
||||
Reference in new issue
Block a user