This class allows you to tap keyboard and mouse and / or to detect their activity even when an application runes in background or does not have any user interface at all. This class raises common .NET events with KeyEventArgs and MouseEventArgs so you can easily retrive any information you need.
Esempio n. 1
0
        /// <summary>
        /// Default constructor of the form Modern.
        /// </summary>
        public Modern()
        {
            InitializeComponent();

            #region Load Save Data

            //Gets and sets the fps
            numMaxFps.Value = Properties.Settings.Default.maxFps;

            //Load last saved window size
            this.Size = new Size(Settings.Default.size.Width, Settings.Default.size.Height);

            //Put the grid as background.
            RightSplit.Panel2.BackgroundImage =
                (con_showGrid.Checked = Settings.Default.ShowGrid) ? //If
                Properties.Resources.grid : null;  //True-False

            //Recording options.
            con_Fullscreen.Checked = Settings.Default.fullscreen;
            con_Snapshot.Checked = Settings.Default.snapshot;

            #endregion

            //Gets the window size and show in the textBoxes
            tbHeight.Text = panelTransparent.Height.ToString();
            tbWidth.Text = panelTransparent.Width.ToString();

            #region Performance and flickering tweaks

            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw |
                          ControlStyles.OptimizedDoubleBuffer |
                          ControlStyles.AllPaintingInWmPaint |
                          ControlStyles.UserPaint, true);

            #endregion

            #region Global Hook

            try
            {
                _actHook = new UserActivityHook();
                _actHook.KeyDown += KeyHookTarget;
                _actHook.Start(false, true);
            }
            catch (Exception) { }

            #endregion

            #region If there is a gif file as argument, read the file and jump directly to the editor.

            if (!String.IsNullOrEmpty(ArgumentUtil.FileName))
            {
                CreateTemp();

                //TODO: Redo this code. It works, but...
                _listFramesEdit = new List<string>();
                _listDelayEdit = new List<int>();

                _listFramesUndo = new List<string>();
                _listDelayUndo = new List<int>();

                _delay = 66; //We should get the true delay.

                AddPictures(ArgumentUtil.FileName);

                int width = _listFramesEdit[0].From().Size.Width < 500 ? 500 : _listFramesEdit[0].From().Size.Width;
                int height = _listFramesEdit[0].From().Size.Height < 300 ? 300 : _listFramesEdit[0].From().Size.Height;

                _lastSize = new Size(width, height);

                btnUndo.Enabled = false;
                btnReset.Enabled = false;

                _listFrames = new List<string>(_listFramesEdit);
                _listDelay = new List<int>(_listDelayEdit);

                this.TopMost = false;

                EditFrames();
                ShowHideButtons(true);

                pictureBitmap.AllowDrop = true;
                _stage = Stage.Editing;
                ArgumentUtil.FileName = null;
            }

            #endregion

            _trayIcon.NotifyIconClicked += NotifyIconClicked;

            #region Detect High DPI Settings

            float dpiX;
            using (Graphics graphics = this.CreateGraphics())
            {
                dpiX = graphics.DpiX;
            }

            if (dpiX > 96)
            {
                if (Settings.Default.showHighDpiWarn)
                {
                    var highDpi = new HighDpi();
                    highDpi.ShowDialog();

                    highDpi.Dispose();
                }
            }
            else
            {
                Settings.Default.showHighDpiWarn = false;
            }

            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor of the Internal page.
        /// </summary>
        public Content(Form caller)
        {
            InitializeComponent();

            //Set as global, the form caller.
            _caller = caller;

            //Gets the recording area size and show in the textBoxes
            tbHeight.Text = panelTransparent.Height.ToString();
            tbWidth.Text = panelTransparent.Width.ToString();

            //Gets the window chrome offset - CHECK
            _offsetX = (_caller.Size.Width - panelTransparent.Width) / 2;
            _offsetY = (_caller.Size.Height - panelTransparent.Height - _offsetX - flowPanel.Height - 1);

            //Starts the global keyboard hook.
            #region Global Hook
            _actHook = new UserActivityHook();
            _actHook.KeyDown += KeyHookTarget;
            _actHook.Start(false, true); //false for the mouse, true for the keyboard.
            #endregion

        }
Esempio n. 3
0
        /// <summary>
        /// Constructor of the Internal page.
        /// </summary>
        public Internal(Form caller)
        {
            InitializeComponent();

            //Set as global, the form caller.
            _caller = caller;

            //Gets the recording area size and show in the textBoxes
            tbHeight.Text = panelTransparent.Height.ToString();
            tbWidth.Text = panelTransparent.Width.ToString();

            //Starts the global keyboard hook.
            #region Global Hook
            _actHook = new UserActivityHook();
            _actHook.KeyDown += KeyHookTarget;
            _actHook.Start(false, true); //false for the mouse, true for the keyboard.
            #endregion
        }