Ejemplo n.º 1
0
        KeyPress ToCarnacKeyPress(InterceptKeyEventArgs interceptKeyEventArgs)
        {
            var process = AssociatedProcessUtilities.GetAssociatedProcess();

            if (process == null)
            {
                return(null);
            }

            // see if this process is one being filtered for
            Regex filterRegex;

            if (ShouldFilterProcess(out filterRegex) && !filterRegex.IsMatch(process.ProcessName))
            {
                return(null);
            }

            var isLetter = interceptKeyEventArgs.IsLetter();
            var inputs   = ToInputs(isLetter, winKeyPressed, interceptKeyEventArgs).ToArray();

            try
            {
                string      processFileName = process.MainModule.FileName;
                ImageSource image           = IconUtilities.GetProcessIconAsImageSource(processFileName);
                return(new KeyPress(new ProcessInfo(process.ProcessName, image), interceptKeyEventArgs, winKeyPressed, inputs));
            }
            catch (Exception)
            {
                return(new KeyPress(new ProcessInfo(process.ProcessName), interceptKeyEventArgs, winKeyPressed, inputs));;
            }
        }
Ejemplo n.º 2
0
        KeyPress ToCarnacKeyPress(InterceptKeyEventArgs interceptKeyEventArgs)
        {
            var process = AssociatedProcessUtilities.GetAssociatedProcess();

            if (process == null)
            {
                return(null);
            }

            Debug.WriteLine("processName: " + process.ProcessName);

            var filterRegex = GetRegEx();

            if (filterRegex != null && !filterRegex.IsMatch(process.ProcessName))
            {
                return(null);
            }

            var isLetter = interceptKeyEventArgs.IsLetter();
            var inputs   = ToInputs(isLetter, winKeyPressed, interceptKeyEventArgs).ToArray();

            try
            {
                string      processFileName = process.MainModule.FileName;
                ImageSource image           = IconUtilities.GetProcessIconAsImageSource(processFileName);
                return(new KeyPress(new ProcessInfo(process.ProcessName, image), interceptKeyEventArgs, winKeyPressed, inputs));
            }
            catch (Exception)
            {
                return(new KeyPress(new ProcessInfo(process.ProcessName), interceptKeyEventArgs, winKeyPressed, inputs));;
            }
        }