Ejemplo n.º 1
0
        private void GlobalHookKeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            string keyUp = e.KeyCode.ToString();

            KeysConverter str = new KeysConverter();


            if (keyUp == hkone)
            {
                if (flagOpen1 == true)
                {
                    CloseRadialMenu1.Execute(null);
                    flagOpen3 = false;
                    flagOpen2 = false;
                    flagOpen1 = false;

                    ClipCursor(IntPtr.Zero);

                    openRightMenu = false;
                }
                else if (flagOpen3 == true)
                {
                    CloseRadialMenu3.Execute(null);
                    flagOpen3 = false;
                    flagOpen2 = false;
                    flagOpen1 = false;
                    ClipCursor(IntPtr.Zero);

                    openRightMenu = false;
                }
            }
            else if (keyUp == hktwo)
            {
                if (flagOpen2 == true)
                {
                    CloseRadialMenu2.Execute(null);
                    flagOpen3 = false;
                    flagOpen2 = false;
                    flagOpen1 = false;
                    ClipCursor(IntPtr.Zero);

                    openRightMenu = false;
                }
                else if (flagOpen3 == true)
                {
                    CloseRadialMenu3.Execute(null);
                    flagOpen3 = false;
                    flagOpen2 = false;
                    flagOpen1 = false;
                    ClipCursor(IntPtr.Zero);

                    openRightMenu = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void GlobalHookKeyPress(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            string keydown = e.KeyCode.ToString();


            if ((keydown == hkone) || (keydown == hktwo))
            {
                if (openRightMenu == false)
                {
                    timerOpenRightMenu.Start();
                }
            }

            if (openRightMenu == true)
            {
                byte[] keys = new byte[256];
                GetKeyboardState(keys);

                string keyDown = e.KeyCode.ToString();

                KeysConverter str      = new KeysConverter();
                int           hkoneint = (int)str.ConvertFromString(hkone);
                int           hktwoint = (int)str.ConvertFromString(hktwo);


                if ((keys[hkoneint] & keys[hktwoint] & 128) == 128)
                {
                    System.Windows.Application.Current.MainWindow.WindowState = WindowState.Maximized;
                    OpenRadialMenu3.Execute(null);
                    CloseRadialMenu2.Execute(null);
                    CloseRadialMenu1.Execute(null);
                    double height = Screen.PrimaryScreen.WorkingArea.Height / 2;
                    double width  = Screen.PrimaryScreen.WorkingArea.Width / 2;

                    middleScreenPosH = (int)width;
                    middleScreenPosV = (int)height;

                    if (flagOpen3 == false)
                    {
                        SetCursorPos(middleScreenPosH, middleScreenPosV);
                        flagOpen1 = false;
                        flagOpen2 = false;
                        flagOpen3 = true;

                        RECT r;

                        r.left   = (int)(width - 90);
                        r.top    = (int)(height - 90);
                        r.right  = (int)(width + 90);
                        r.bottom = (int)(height + 90);
                        ClipCursor(ref r);
                    }
                }
                else if ((keys[hkoneint] & 128) == 128)
                {
                    System.Windows.Application.Current.MainWindow.WindowState = WindowState.Maximized;
                    OpenRadialMenu1.Execute(null);
                    CloseRadialMenu2.Execute(null);
                    CloseRadialMenu3.Execute(null);
                    double height = Screen.PrimaryScreen.WorkingArea.Height / 2;
                    double width  = Screen.PrimaryScreen.WorkingArea.Width / 2;

                    middleScreenPosH = (int)width;
                    middleScreenPosV = (int)height;

                    if (flagOpen1 == false)
                    {
                        SetCursorPos(middleScreenPosH, middleScreenPosV);
                        flagOpen1 = true;
                        flagOpen2 = false;
                        flagOpen3 = false;

                        RECT r;

                        r.left   = (int)(width - 90);
                        r.top    = (int)(height - 90);
                        r.right  = (int)(width + 90);
                        r.bottom = (int)(height + 90);



                        ClipCursor(ref r);
                    }
                }
                else if ((keys[hktwoint] & 128) == 128)
                {
                    System.Windows.Application.Current.MainWindow.WindowState = WindowState.Maximized;
                    OpenRadialMenu2.Execute(null);
                    CloseRadialMenu1.Execute(null);
                    CloseRadialMenu3.Execute(null);
                    double height = Screen.PrimaryScreen.WorkingArea.Height / 2;
                    double width  = Screen.PrimaryScreen.WorkingArea.Width / 2;

                    middleScreenPosH = (int)width;
                    middleScreenPosV = (int)height;

                    if (flagOpen2 == false)
                    {
                        SetCursorPos(middleScreenPosH, middleScreenPosV);
                        flagOpen2 = true;
                        flagOpen1 = false;
                        flagOpen3 = false;

                        RECT r;

                        r.left   = (int)(width - 90);
                        r.top    = (int)(height - 90);
                        r.right  = (int)(width + 90);
                        r.bottom = (int)(height + 90);
                        ClipCursor(ref r);
                    }
                }
            }
        }