Improve IK-style artifact scanner pipeline

This commit is contained in:
AzuTear
2026-07-07 22:02:24 +02:00
parent 8ebbe91c39
commit f791d1464c
70 changed files with 7408 additions and 445 deletions
+42
View File
@@ -169,6 +169,23 @@ internal static class Program
break;
}
case "key":
{
var info = FocusGenshinWindow();
if (info.Focused && !info.AlreadyForeground) Thread.Sleep(120);
var key = GetString(root, "key");
var sent = SendKeyPressBatch(ResolveVirtualKey(key));
response["key"] = key;
response["focused"] = info.Focused;
response["foregroundProcess"] = info.ForegroundProcess;
response["targetProcess"] = info.TargetProcess;
response["isElevated"] = IsElevated();
response["eventsSent"] = sent;
response["inputBlocked"] = sent < 2;
break;
}
case "bounds":
{
var bounds = GetGenshinClientBounds();
@@ -423,6 +440,30 @@ internal static class Program
return Native.SendInput(1, inputs, Marshal.SizeOf<Native.INPUT>());
}
private static uint SendKeyPressBatch(int virtualKey)
{
var inputs = new Native.INPUT[2];
inputs[0].type = 1; // INPUT_KEYBOARD
inputs[0].mi.dx = virtualKey; // same union bytes as KEYBDINPUT.wVk
inputs[1].type = 1;
inputs[1].mi.dx = virtualKey;
inputs[1].mi.dy = Native.KEYEVENTF_KEYUP; // same union bytes as KEYBDINPUT.dwFlags
return Native.SendInput(2, inputs, Marshal.SizeOf<Native.INPUT>());
}
private static int ResolveVirtualKey(string key)
{
return key.Trim().ToUpperInvariant() switch
{
"ESC" or "ESCAPE" => 0x1B,
"ENTER" => 0x0D,
"B" => 0x42,
"C" => 0x43,
"1" => 0x31,
_ => throw new ArgumentOutOfRangeException(nameof(key), $"unsupported key: {key}")
};
}
private static string GetString(JsonElement root, string name)
=> root.TryGetProperty(name, out var value) ? value.ToString() : "";
@@ -445,6 +486,7 @@ internal static class Native
public const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
public const uint MOUSEEVENTF_LEFTUP = 0x0004;
public const uint MOUSEEVENTF_WHEEL = 0x0800;
public const int KEYEVENTF_KEYUP = 0x0002;
public const uint SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000;
public const uint SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001;
public const uint SPIF_SENDCHANGE = 0x0002;