【发布时间】:2020-06-07 04:09:48
【问题描述】:
我点击转发按钮,它会发送字符串,但我不能使用 winform 发送字符串给它来修改它
我发现罗技有G-series Lua API
我尝试使用 OnEvent 函数来控制鼠标点击发送字符串
但我以前从未使用 Lua。
这是我的 C# 代码
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using LuaInterface;
namespace LuaScript
{
public partial class Form1 : Form
{
public Lua lua = new Lua();
string var = "aabbcc";
public Form1()
{
InitializeComponent();
lua.DoFile("logitechSendString.lua");
object[] objs = lua.GetFunction("OnEvent").Call(this, var);
lua.Close();
}
}
}
我的 lua 代码
function OnEvent(event, arg)
if (arg!=null)then
PressKey(arg)
ReleaseKey(arg)
Sleep(50)
PressMouseButton("Forward")
ReleaseMouseButton("Forward")
end
end
但它符合错误
System.IO.FileLoadException
HResult=0x80131621
Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
Source=LuaInterface
StackTrace:
LuaInterface.Lua..ctor()
LuaScript.Form1..ctor() D:\Visual Studio\LuaScript\LuaScript\Form1.cs: 15
LuaScript.Program.Main() D:\Visual Studio\LuaScript\LuaScript\Program.cs:19
如何解决这个错误?
以及如何使用lua控制鼠标?
谢谢
【问题讨论】:
-
G 系列 Lua API 仅适用于在罗技游戏软件中运行的 Lua 脚本。外部程序(如您的 C# 程序)无法访问此 API。
-
模拟
mouse button #5 X2(Forward)按下并释放你根本不需要Lua。这可以在 C# 中本地完成。 -
如果您只是想在按下鼠标按钮
Forward时模拟输入一些消息,那么您需要在 Logitech 游戏软件中创建一个宏(在您的图片)。通过拖放宏名称将创建的宏绑定到鼠标按钮。 -
嗨 Evor 感谢您的回答我尝试使用 sg300 因为它包含内存它可以存储来自 winform 的字符串我只需要它来存储字符串并通过点击鼠标发送,或者我可以简单地模拟点击和发送字符串.
标签: c# winforms lua logitech-gaming-software