Exemple #1
0
        /// <summary>
        /// KeyDown event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void KListener_KeyDown(object sender, RawKeyEventArgs args)
        {
            try
            {
                SetKeyDown(args.Key);

                // Ctrl + F11 (Action on foreground app)
                if (IsKeyDown(Key.LeftCtrl) && IsKeyDown(Key.F11))
                {
                    WindowHandler.ChangeBorderStyle(WindowLib.GetForegroundWindow());
                }
                // Ctrl + F12 (Adds / Removes foreground app to / from list)
                else if (IsKeyDown(Key.LeftCtrl) && IsKeyDown(Key.F12))
                {
                    ProcessInfos.AddOrRemove(this.Processes);
                }
            }
            catch { }
        }
Exemple #2
0
        /// <summary>
        /// Parcours la liste des processus actifs pour forcer le traitement sur les processus de la liste blanche
        /// </summary>
        private static void ListenProcesses()
        {
            while (true)
            {
                try
                {
                    Thread.Sleep(1000);

                    if (_Whitelist.Count > 0)
                    {
                        // Vérification du besoin de traiter la fenêtre actuelle
                        IntPtr hWnd = WindowLib.GetForegroundWindow();

                        if (!_ExcludedhWnd.Any(x => x == hWnd) && (hWnd != _lasthWnd || (hWnd == _lasthWnd && _IsSuccessful == false)))
                        {
                            uint actProcessId = 0;
                            WindowLib.GetWindowThreadProcessId(hWnd, out actProcessId);
                            Process actProcess = Process.GetProcessById((int)actProcessId);

                            if (_Whitelist.Any(i => i.Name.ToUpper() == actProcess.ProcessName.ToUpper()))
                            {
                                ChangeBorderStyle(hWnd, actProcess);
                            }

                            _lasthWnd     = hWnd;
                            _IsSuccessful = true;
                        }
                        // Nettoyage des handle stockés
                        foreach (IntPtr StockedhWnd in _ExcludedhWnd)
                        {
                            uint StockedProcessId = 0;
                            WindowLib.GetWindowThreadProcessId(StockedhWnd, out StockedProcessId);

                            if (StockedProcessId == 0)
                            {
                                _ExcludedhWnd.Remove(StockedhWnd);
                            }
                        }
                    }
                }
                catch { }
            }
        }