Beispiel #1
0
        public MainWindow()
        {
            Title   = "Input Mapper";
            Content = new Grid
            {
            };

            _input = new InputSimulator();
            _mouse = new HookMouse();
            _init  = Task.Run(async() =>
            {
                var file = new FileInfo("./mappings.json");
                if (file.Exists)
                {
                    using var stream = File.OpenRead("./mappings.json");
                    var mappings     = await Jsonizer.DeserializeAsync <List <InputMapping> >(stream);
                    foreach (var m in mappings)
                    {
                        _mappings.GetOrAdd(m.Trigger).Add(m);
                    }
                }
                _mappings.GetOrAdd(MouseAction.XButton2Up).Add(new InputMapping
                {
                    Trigger             = MouseAction.XButton2Up,
                    Modifiers           = new[] { VirtualKeyCode.CONTROL },
                    Keys                = new[] { VirtualKeyCode.VK_W },
                    IncludedFiles       = new[] { "chrome.exe" },
                    ExcludedWindowNames = new[] { "Play - Stadia" },
                });
                _mappings.GetOrAdd(MouseAction.XButton1Up).Add(new InputMapping
                {
                    Trigger             = MouseAction.XButton1Up,
                    Modifiers           = new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT },
                    Keys                = new[] { VirtualKeyCode.LBUTTON },
                    IncludedFiles       = new[] { "chrome.exe" },
                    ExcludedWindowNames = new[] { "Play - Stadia" },
                });
                _mouse.On += _mouse_On;
            });
        }