Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Winform use lua to control Mouse

$
0
0

I try to use Logitech mouse to send string

I click Forward button it will send string but I can't use winform to send string to it to modify it

I find logitech has G-sries Lua API

https://douile.github.io/logitech-toggle-keys/APIDocs.pdf

I try to use OnEvent function to control mouse click to send string

But I never Lua before.

Here is my c# code

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();
        }
    }
}

My lua code

function OnEvent(event, arg)
        if (arg!=null)then
                PressKey(arg) 
		ReleaseKey(arg)
    		Sleep(50)
		PressMouseButton("Forward")
		ReleaseMouseButton("Forward")

        end
end

But it complie error

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

How to solve this error?

And How to do use lua to control Mouse?

Thanks



Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>