Files
better-genshin-impact/BetterGenshinImpact/Core/Simulator/Simulation.cs
FishmanTheMurloc 29a2c0069e bug fix:拉条过程中内存没有及时释放 (#1266)
* bug fix:拉条过程中内存没有及时释放

* 新增LiftAndHold行为用于举竿、检测预抛竿时鼠标左键是否被意外松开、终止任务;抛竿开始后5秒内如从未找到落点,则返回失败,并配有单元测试;添加抛竿时无鱼饵适用鱼的单元测试;调整变量名

* 新增一个钓鱼昼夜设置枚举DontChange及其逻辑(枚举值为3),表示不调整时间直接开钓

* 针对可能是游戏中的雾气/滤镜/小黄鸭之类不明原因干扰了钓鱼拉条框的识别,修改了CV算法,使其不严格按照黄色(255,255,192)找矩形,而是按一定HSV范围寻找,并加强过滤;添加上述不明原因案例的测试用例

* 将MySimpleParallel改造为支持两个以上子行为;将“检查抛竿结果”行为合并到“下杆中”并行节点,以去除检查的等待时间,由此希望能应对鱼过快上钩的情况
2025-03-14 00:17:37 +08:00

41 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Fischless.WindowsInput;
using System;
using BetterGenshinImpact.GameTask.Common;
using Microsoft.Extensions.Logging;
using Vanara.PInvoke;
namespace BetterGenshinImpact.Core.Simulator;
public class Simulation
{
public static InputSimulator SendInput { get; } = new();
public static MouseEventSimulator MouseEvent { get; } = new();
public static PostMessageSimulator PostMessage(IntPtr hWnd)
{
return new PostMessageSimulator(hWnd);
}
public static void ReleaseAllKey()
{
foreach (User32.VK key in Enum.GetValues(typeof(User32.VK)))
{
// 检查键是否被按下
if (IsKeyDown(key)) // 强制转换 VK 枚举为 int
{
TaskControl.Logger.LogDebug($"解除{key}的按下状态.");
SendInput.Keyboard.KeyUp(key);
}
}
}
public static bool IsKeyDown(User32.VK key)
{
// 获取按键状态
var state = User32.GetAsyncKeyState((int)key);
// 检查高位是否为 1表示按键被按下
return (state & 0x8000) != 0;
}
}