Example #1
0
        //Open/close Keyboard button handle
        void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                this.Opacity = 1;
                if ((GetWindowLong(FindWindow("IPTip_Main_Window", null), -16) & 0x8000000) != 0 || Process.GetProcessesByName("osk").Length == 0 && Process.GetProcessesByName("TabTip").Length == 0)
                {
                    try
                    {
                        //Open TabTip / On Screen Keyboard
                        if (ConfigurationManager.AppSettings["KeyboardType"] == "0")
                        {
                            Process.Start("C:\\Program Files\\Common Files\\Microsoft Shared\\ink\\TabTip.exe");
                        }
                        else
                        {
                            Process.Start("C:\\Windows\\System32\\osk.exe");
                        }

                        //Focus back on active window
                        Process FocusProcess = Process.GetProcessById(DetectKeyboard.ActiveProcessFocusId);
                        if (FocusProcess.ProcessName != "explorer")
                        {
                            SetForegroundWindow(FocusProcess.MainWindowHandle);
                        }
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        //Close TabTip / On Screen Keyboard
                        SendMessage(FindWindow("IPTip_Main_Window", null), 0x0112, (IntPtr)0xF060, IntPtr.Zero);
                        foreach (Process KillProc in Process.GetProcessesByName("osk"))
                        {
                            KillProc.Kill();
                        }

                        //Focus back on active window
                        Process FocusProcess = Process.GetProcessById(DetectKeyboard.ActiveProcessFocusId);
                        if (FocusProcess.ProcessName != "explorer")
                        {
                            SetForegroundWindow(FocusProcess.MainWindowHandle);
                        }
                    }
                    catch { }
                }
            }
            catch { }
        }
Example #2
0
 //Detect Keyboard Requests
 public void DetectKeyBoard()
 {
     while (true)
     {
         try
         {
             AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero), GetCurrentThreadId(), true);
             IntPtr GetFocusId = GetFocus();
             AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero), GetCurrentThreadId(), false);
             if (GetClassName(GetFocusId, StringBuilder, StringBuilder.Capacity))
             {
                 ActiveProcessFocus = StringBuilder.ToString();
                 if (PreviousProcessFocus != ActiveProcessFocus && !ActiveProcessFocus.Contains("KeyboardOpener"))
                 {
                     if (ActiveProcessFocus == "Edit" || ActiveProcessFocus == "SearchPane" || ActiveProcessFocus.Contains("RichEdit") || ActiveProcessFocus.Contains("SearchEdit") || ActiveProcessFocus.Contains("TextfieldEdit") || ActiveProcessFocus.Contains("Afx:00400000") || ActiveProcessFocus == "_WwG" || ActiveProcessFocus == "Scintilla" || ActiveProcessFocus == "SPEAD0C4")
                     {
                         try
                         {
                             //Open TabTip / On Screen Keyboard
                             if (ConfigurationManager.AppSettings["KeyboardType"] == "0")
                             {
                                 Process.Start("C:\\Program Files\\Common Files\\Microsoft Shared\\ink\\TabTip.exe");
                             }
                             else
                             {
                                 Process.Start("C:\\Windows\\System32\\osk.exe");
                             }
                         }
                         catch { }
                     }
                     else
                     {
                         try
                         {
                             //Close TabTip / On Screen Keyboard
                             SendMessage(FindWindow("IPTip_Main_Window", null), 0x0112, (IntPtr)0xF060, IntPtr.Zero);
                             foreach (Process KillProc in Process.GetProcessesByName("osk"))
                             {
                                 KillProc.Kill();
                             }
                         }
                         catch { }
                     }
                     PreviousProcessFocus = ActiveProcessFocus;
                 }
             }
             Thread.Sleep(250);
         }
         catch { }
     }
 }
Example #3
0
        //Exit the application
        void OnExit(object sender, EventArgs e)
        {
            try
            {
                //Close TabTip / On Screen Keyboard
                SendMessage(FindWindow("IPTip_Main_Window", null), 0x0112, (IntPtr)0xF060, IntPtr.Zero);
                foreach (Process KillProc in Process.GetProcessesByName("osk"))
                {
                    KillProc.Kill();
                }

                NotifyIcon.Visible = false;
                Environment.Exit(1);
            }
            catch { }
        }