none
Winform use lua to control Mouse RRS feed

  • Question

  • 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


    • Edited by CY_Chen Sunday, February 23, 2020 8:05 AM
    • Moved by Sheng Jiang 蒋晟 Sunday, February 23, 2020 8:02 PM not winforms related
    Sunday, February 23, 2020 8:05 AM

All replies

  • Ask Logitech to provide a .Net 4.0 version of LuaInterface.

    You can also modify your app.config file to use the legacy run time behavior (search the error message and you will find plenty of examples). 

    As for how to use the LuaInterface assembly, contact Logitech developer support. 



    Visual C++ MVP

    Monday, February 24, 2020 2:45 AM