Ejemplo n.º 1
0
        /// <summary>
        /// Sends a message, regardless to the auto type and it's settings..
        /// </summary>
        /// <param name="text"></param>
        /// <param name="OnlyInSpecificProcess"> </param>
        /// <returns>Succeeded sending the message to the specific process. if OnlyInSpecificProcess = false, returns true always</returns>
        public bool SendMessage(string text, bool OnlyInSpecificProcess = false)
        {
            if (Disposed || (OnlyInSpecificProcess == true && ProcessBeingFocused == null))
            {
                return(false);
            }
            var FocusedProc = ProcessFinder.GetForegroundProcess();

            if (Process.GetCurrentProcess().Id == FocusedProc.Id)
            {
                return(false);
            }
            if (!OnlyInSpecificProcess || FocusedProc.Id == ProcessBeingFocused.UniqueID)
            {
                KeySender.SendText(text);
                KeySender.PressKey(KeyCode.Return);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Handles a key press event
        /// </summary>
        private void OnKeyPress(BaseKeyboardManager sender, HotkeyEventArgs args)
        {
            //handles which process was it hit on,

            var topmost = ProcessFinder.GetForegroundProcess().ToProcessInfo();

            var topmost_log = ActiveLogs.FirstOrDefault(log => log.Process.Equals(topmost));

            if (topmost_log == null)
            {
                ActiveLogs.Add(topmost_log = new ProcessLog()
                {
                    Process = topmost
                });
                topmost_log.LineClosed += line => LineClosed?.Invoke(line);
            }
            //Convert Hotkey to LogKey - includes in keyboardlayout
            var lk = new LogKey {
                Key = args.Hotkey.Key, Modifiers = args.Hotkey.Modifiers, KeyboardLayout = KeyboardLanguage.GetCurrentKeyboardLayout()
            };                                                                                                                                              //67699721 hebrew?

            topmost_log.AddContent(lk);
        }