Esempio n. 1
0
        private void OnHotKeyPressed(object sender, KeyPressedEventArgs e)
        {
            var kc = new KeyConverter();

            if (e.HotKey.Key == (Key)kc.ConvertFromString(Settings.Default.hotKeyQ))
            {
                ForegroundW.SetForeground("Shell_TrayWnd");
                textBox.Focus();
                textBox.Clear();
            }
            if (e.HotKey.Key == (Key)kc.ConvertFromString(Settings.Default.hotKeyW))
            {
                if (Shower == null)
                {
                    Shower = new QShower();
                }

                Shower.ShowOrHide(ActualHeight, ActualWidth, PointToScreen(new Point()).X);
            }
            if (e.HotKey.Key == (Key)kc.ConvertFromString(Settings.Default.hotKeyB))
            {
                Sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
                Thread.Sleep(20);
                string str = ClipboardGetText();
                Process.Start("https://www.baidu.com/s?ie=UTF-8&wd=" + str);
            }
            if (e.HotKey.Key == (Key)kc.ConvertFromString(Settings.Default.hotKeyG))
            {
                Sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
                Thread.Sleep(20);
                string str = ClipboardGetText();
                Process.Start("http://google.com#q=" + str);
            }
        }
Esempio n. 2
0
 // 打开输入框
 private void Logo_MouseEnter(object sender, MouseEventArgs e)
 {
     // 必须借助真实鼠标/键盘按键 SetForeground函数 才能抢到焦点。
     Sim.Mouse.Keyboard.KeyUp(VirtualKeyCode.RIGHT);
     ForegroundW.SetForeground("Shell_TrayWnd");
     textBox.Focus();
     textBox.SelectionStart = textBox.Text.Length;
 }