private static void OnHotKeyPressed(HotKeyEventArgs e)
 {
     if (HotKeyManager.HotKeyPressed != null)
     {
         HotKeyManager.HotKeyPressed(null, e);
     }
 }
Example #2
0
        private static void HotKeyManager_HotKeyPressed(object sender, HotKeyEventArgs e)
        {
            var foreGround = GetForegroundWindow();
            System.Diagnostics.Process me = System.Diagnostics.Process.GetCurrentProcess();
            var processes = Process.GetProcesses();
            var list = processes.Where(p => p.ProcessName == "explorer");

            var isSimplifiedEnable = BopomofoRegistry.IsSimplifiedEnable();

            if (list.Any())
            {
                var handle = list.First().MainWindowHandle;
                SwitchToThisWindow(handle, true);
                SetActiveWindow(handle);
            }

            Thread.Sleep(100);

            if (isSimplifiedEnable)
            {
                Console.WriteLine("Disable");
                BopomofoRegistry.EnableSimplified(false);
            }
            else
            {
                Console.WriteLine("Enable");
                BopomofoRegistry.EnableSimplified(true);
            }

            isSimplifiedEnable = BopomofoRegistry.IsSimplifiedEnable();
            pi.SetTextModeText(isSimplifiedEnable);

            SwitchToThisWindow(foreGround, true);
            SetActiveWindow(foreGround);
        }
            protected override void WndProc(ref Message m)
            {
                if (m.Msg == WM_HOTKEY)
                {
                    HotKeyEventArgs e = new HotKeyEventArgs(m.LParam);
                    HotKeyManager.OnHotKeyPressed(e);
                }

                base.WndProc(ref m);
            }