babalae/better-genshin-impact · error · ArgumentException
{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]}
Error message
{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]} 不合法 What it means
Error "{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]} 不合法" thrown in babalae/better-genshin-impact.
Source
Thrown at BetterGenshinImpact/GameTask/AutoFight/Script/CombatCommand.cs:67
}
else if (Method == Method.W || Method == Method.A || Method == Method.S || Method == Method.D)
{
AssertUtils.IsTrue(Args.Count == 1, "w/a/s/d方法必须有一个入参,代表行走时间。例:d(0.5)");
}
else if (Method == Method.MoveBy)
{
AssertUtils.IsTrue(Args.Count == 2, "moveby方法必须有两个入参,分别是x和y。例:moveby(100, 100))");
}
else if (Method == Method.KeyDown || Method == Method.KeyUp || Method == Method.KeyPress)
{
AssertUtils.IsTrue(Args.Count == 1, $"{Method.Alias[0]}方法必须有一个入参,代表按键");
try
{
User32Helper.ToVk(Args[0]);
}
catch
{
throw new ArgumentException($"{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]} 不合法");
}
}
else if (Method == Method.Scroll)
{
AssertUtils.IsTrue(Args.Count == 1, "scroll方法必须有一个入参,代表滚动格数。例:scroll(1) 或 scroll(-1)");
AssertUtils.IsTrue(int.TryParse(Args[0], out _), "滚动格数必须是整数");
}
}
public override string ToString()
{
return $"<CombatCommand {Name}, {Method}({Args}) (rounds {ActivatingRound})>";
}
public void Execute(CombatScenes combatScenes, CombatCommand? lastCommand = null)
{
Avatar? avatar;
if (Name == CombatScriptParser.CurrentAvatarName)View on GitHub (pinned to a7cb36712d)
Solutions
- 检查战斗脚本中该方法使用的按键名,必须是 VirtualKeyCodes 枚举中的合法值
- 参考按键表使用如 VK_SPACE、VK_E 等标准按键名
Example fix
按键参数改为 VirtualKeyCodes 枚举中的合法值(如 VK_F、VK_SPACE 或支持的键名),核对脚本拼写。
When it happens
Trigger: 战斗脚本中 keydown/keyup/keypress 指令的按键参数无法通过 User32Helper.ToVk 转换为合法虚拟键码时抛出。
Common situations: 脚本里写了不存在的按键名,如 keypress(xxx) 拼写错误或使用了不支持的键。
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/8f3e0cca46314629.
Report an issue: GitHub.