Exemplo n.º 1
0
        private void Main_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;

            //Build a context menu of the winform
            ContextMenu contextMenu  = new ContextMenu();
            MenuItem    menu_setting = new MenuItem("Setting");
            MenuItem    menu_quit    = new MenuItem("Quit");

            contextMenu.MenuItems.Add(menu_setting);
            contextMenu.MenuItems.Add(menu_quit);
            this.ContextMenu        = contextMenu;
            notifyIcon1.ContextMenu = contextMenu;
            //bind the menu and its event handler
            menu_quit.Click    += quit;
            menu_setting.Click += setting;

            //注册热键 (窗体句柄,热键ID,辅助键,实键)
            //辅助键说明: None = 0,   Alt = 1,  crtl= 2,  Shift = 4,   Windows = 8
            //如果有多个辅助键则,例如 alt+crtl是3 直接相加就可以了
            RegisterHotKey(this.Handle, 123, 1, Keys.R);
            run = new RunForm();

            int x = Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width;
            int y = Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height;

            this.SetDesktopLocation(x, y);

            //synth.Speak("鹏神哈哈哈哈!");

            ThreadStart threadStart = new ThreadStart(loop);
            Thread      thread      = new Thread(threadStart);

            thread.Start();
        }
Exemplo n.º 2
0
 //处理快捷键消息
 protected override void WndProc(ref Message m)
 {
     switch (m.Msg)
     {
     case 0x0312:
         if (m.WParam.ToString() == "123")
         {
             if (run.IsDisposed)
             {
                 run = new RunForm();
                 run.Show();
             }
             else
             {
                 run.Visible = !run.Visible;
             }
             if (run.Visible)
             {
                 SetForegroundWindow(run.Handle);
                 run.clearInput();
             }
         }
         break;
     }
     base.WndProc(ref m);
 }