Exemple #1
0
        void CheckDevice(ref Message msg)
        {
            IntPtr devinfo = Win32.SetupDiGetClassDevs(ref
                                                       Win32.GUID_DEVCLASS_MOUSE, IntPtr.Zero, IntPtr.Zero, Win32.DIGCF_PRESENT);

            Win32.SP_DEVINFO_DATA devInfoSet = new Win32.SP_DEVINFO_DATA
            {
                cbSize = Marshal.SizeOf(typeof(Win32.SP_DEVINFO_DATA))
            };
            if (Win32.SetupDiEnumDeviceInfo(devinfo, 0, ref devInfoSet))
            {
                int wParam = (int)msg.WParam;
                if (wParam == Win32.DBT_DEVICEARRIVAL)
                {
                    _isTouchpadOnly = false;
                    label1.Text     = Resources.TouchpadAdnMouse;
                    SetSpeed(mouseBar.Value);
                    //notifyIcon1.ShowBalloonTip(1000, "AutoSensitivity", "Mouse connected", ToolTipIcon.Info);
                }
                else if (wParam == Win32.DBT_DEVICEREMOVECOMPLETE)
                {
                    _isTouchpadOnly = true;
                    label1.Text     = Resources.TouchpadOnly;
                    SetSpeed(touchpadBar.Value);
                    //notifyIcon1.ShowBalloonTip(1000, "AutoSensitivity", "Mouse disconnected", ToolTipIcon.Info);
                }
            }
        }
Exemple #2
0
        /*private static bool SetRunAtStartup(bool setStarting)
         * {
         *  try
         *  {
         *      RegistryKey rkApp = Registry.CurrentUser.OpenSubKey(
         *          "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
         *      if (rkApp==null)
         *      {
         *          return false;
         *      }
         *      if (setStarting)
         *      {
         *          rkApp.SetValue("AutoSensitivity", Application.ExecutablePath.ToString());
         *      } else
         *      {
         *          if (rkApp.GetValue("AutoSensitivity") != null)
         *          {
         *              rkApp.DeleteValue("AutoSensitivity", false);
         *          }
         *      }
         *  }
         *  catch
         *  {
         *      return false;
         *  }
         *
         *  return true;
         * }*/

        private void InitSettings()
        {
            int    count   = 0;
            IntPtr devinfo = Win32.SetupDiGetClassDevs(
                ref Win32.GUID_DEVCLASS_MOUSE,
                IntPtr.Zero,
                IntPtr.Zero,
                Win32.DIGCF_PRESENT);

            Win32.SP_DEVINFO_DATA devInfoSet =
                new Win32.SP_DEVINFO_DATA
            {
                cbSize = Marshal.SizeOf(typeof(Win32.SP_DEVINFO_DATA))
            };

            //List<string> devices = new List<string>();
            while (Win32.SetupDiEnumDeviceInfo(devinfo, count,
                                               ref devInfoSet))
            {
                count++;
                //devices.Add(devInfoSet.DevInst.ToString());
            }
            _isTouchpadOnly          = count <= 1;
            label1.Text              = count <= 1 ? Resources.TouchpadOnly: Resources.TouchpadAdnMouse;
            runAtStartupCB.Checked   = IsRunningAtStartup();//Settings.Default.RunAtStartup;
            startMinimizedCB.Checked = Settings.Default.StartMinimized;
            if (Settings.Default.StartMinimized)
            {
                Hide();
            }
        }
        private void DetectInputDevices()
        {
            int count = 0;
            IntPtr devinfo = Win32.SetupDiGetClassDevs(
                ref Win32.GUID_DEVCLASS_MOUSE,
                IntPtr.Zero,
                IntPtr.Zero,
                Win32.DIGCF_PRESENT);
            Win32.SP_DEVINFO_DATA devInfoSet =
                new Win32.SP_DEVINFO_DATA
                {
                    cbSize = Marshal.SizeOf(typeof(Win32.SP_DEVINFO_DATA))
                };

            while (Win32.SetupDiEnumDeviceInfo(devinfo, count, ref devInfoSet))
            {
                count++;
            }
            _isTouchpadOnly = count <= 1;
            labelTouchpadMouseStatus.Text = _isTouchpadOnly ? Resources.TouchpadOnly : Resources.TouchpadAdnMouse;
        }