Exemple #1
0
        private void RunDriverThread()
        {
            //create and init
            _rmInput = new RawMouseInput();
            if (_rmInput == null)
            {
                MessageBox.Show("ERROR: could not create rawinput class");
            }

            _driverWindow = new DriverWindow(_rmInput);
            if (_driverWindow == null)
            {
                MessageBox.Show("ERROR: could not create driverwindow class");//error
            }

            _rmInput.RegisterForWM_INPUT(_driverWindow.Handle);
            _filter = new PreMessageFilter();
            if (_filter == null)
            {
                MessageBox.Show("ERROR: could not add premessage filter"); //error
            }

            Application.AddMessageFilter(_filter);
            Application.Run(_driverWindow);
            Application.RemoveMessageFilter(_filter);

            if (_driverWindow.IsDisposed == false)
            {
                _driverWindow.Dispose();
            }
            _driverWindow = null;
            _rmInput      = null;
        }
Exemple #2
0
        public void Awake()
        {
            RawMouseInput.Start(workInBackground: true);
            RawMouseInput.OnMouseMove     += OnMouseMove;
            RawMouseInput.OnMouseLeftDown += OnMouseLeftDown;

            FrameworkEx.Initialize();

            for (int i = 0; i < _NumIcons; ++i)
            {
                _Representation.Add(DesktopEx.CreateDirectory($"tail[{i}]"));
            }
        }
Exemple #3
0
        public void OnDestroy()
        {
            RawMouseInput.Stop();
            RawMouseInput.OnMouseMove     -= OnMouseMove;
            RawMouseInput.OnMouseLeftDown -= OnMouseLeftDown;

            foreach (var directory in _Representation)
            {
                directory.Delete();
            }

            FrameworkEx.Cleanup();
        }
Exemple #4
0
        public Mouse()
        {
            InitializeComponent();
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            _rawMouseInput = new RawMouseInput(Handle, CaptureOnlyInForeground);

            _rawMouseInput.AddMessageFilter();   // Adding a message filter will cause keypresses to be handled
            //Win32.DeviceAudit();            // Writes a file DeviceAudit.txt to the current directory
            if (_rawMouseInput.NumberOfMouses > 1)
            {
                _rawMouseInput.MouseMoved += OnMouseMoved;
            }
        }
        private void RegisterMice()
        {
            rawMouseInput = new RawMouseInput();
            rawMouseInput.RegisterForWM_INPUT(System.Windows.Forms.Control.FromHandle(Game1.game1.Window.Handle).FindForm().Handle);            //form.handle
            System.Windows.Forms.Application.AddMessageFilter(new PreMessageFilter());

            foreach (object rawMouseObj in rawMouseInput.Mice)
            {
                if (rawMouseObj != null)
                {
                    mice.Add((RawMouse)rawMouseObj);
                }
            }
            Console.WriteLine($"Registered mouse driver, found {mice.Count} mice");
        }
Exemple #6
0
        /// <summary>
        /// Create a new driverwindow and register that window to receive WM_INPUT messages from RawMouseInput
        /// </summary>
        private void RunDriverThread()
        {
            // Create and initialise array of all rawmice
            _rmInput = new RawMouseInput();
            if (_rmInput == null)
            {
                MessageBox.Show("ERROR: could not create rawinput class");
            }

            // Create driver window to receive WM_INPUT messages
            try {
                _driverWindow = new InputCaptureWindow(_rmInput);
            }
            catch (Exception e) {; }

            if (_driverWindow == null)
            {
                MessageBox.Show("ERROR: could not create driverwindow class");
            }

            // Register the window to receive raw input
            _rmInput.RegisterForWM_INPUT(_driverWindow.Handle);

            // Create a message filter
            _filter = new PreMessageFilter();
            if (_filter == null)
            {
                MessageBox.Show("ERROR: could not add premessage filter");
            }

            // Apply the filter
            Application.AddMessageFilter(_filter);

            // Load the form and begin the main message pump loop
            Application.Run(_driverWindow);

            // FOLLOWING LINES ONLY EXECUTE WHEN driverWindow EXITS!
            // Remove the message filter
            Application.RemoveMessageFilter(_filter);

            // Clean up
            if (_driverWindow.IsDisposed == false)
            {
                _driverWindow.Dispose();
            }
            _driverWindow = null;
            _rmInput      = null;
        }
        public void RegisterMice()
        {
            if (hasRegistered)
            {
                return;
            }
            hasRegistered = true;

            rawMouseInput = new RawMouseInput();
            rawMouseInput.RegisterForWM_INPUT(System.Windows.Forms.Control.FromHandle(Terraria.Main.instance.Window.Handle).FindForm().Handle);            //form.handle
            System.Windows.Forms.Application.AddMessageFilter(new PreMessageFilter());

            foreach (object rawMouseObj in rawMouseInput.Mice)
            {
                if (rawMouseObj != null)
                {
                    mice.Add((RawMouse)rawMouseObj);
                }
            }
            Console.WriteLine($"Registered mouse driver, found {mice.Count} mice");
        }
 public InputCaptureWindow(RawMouseInput input)
 {
     InitializeComponent();
     _rawinput = input;
 }
Exemple #9
0
 void Awake()
 {
     RawMouseInput.Start(workInBackground: true);
     RawMouseInput.OnMouseRightDown += OpenNewWallpaper;
 }
Exemple #10
0
 void OnDestroy()
 {
     RawMouseInput.Stop();
 }
 public DriverWindow(RawMouseInput input)
 {
     InitializeComponent();
     _rawinput = input;
 }