Beispiel #1
0
        public static async Task SnapCurrentWindowClean(List <SnappingDirection> dirs, int delay = SNAPPING_DELAY)
        {
            //press windows key
            VirtualKeyboard.KeyDown(VirtualKeyCode.VK_LWIN);

            //press all other keys
            VirtualKeyCode key = VirtualKeyCode.VK_UP;

            foreach (SnappingDirection dir in dirs)
            {
                //get key for direction
                switch (dir)
                {
                case SnappingDirection.LEFT:
                    key = VirtualKeyCode.VK_LEFT;
                    break;

                case SnappingDirection.RIGHT:
                    key = VirtualKeyCode.VK_RIGHT;
                    break;

                case SnappingDirection.TOP:
                    key = VirtualKeyCode.VK_UP;
                    break;

                case SnappingDirection.BOTTOM:
                    key = VirtualKeyCode.VK_DOWN;
                    break;
                }

                VirtualKeyboard.KeyDown(key);
                VirtualKeyboard.KeyUp(key);
                await Task.Delay(delay);
            }

            VirtualKeyboard.KeyUp(VirtualKeyCode.VK_LWIN);
            await Task.Delay(delay);

            //if left or right was last operation, "select window for other side"-tool pops up
            if (key == VirtualKeyCode.VK_LEFT || key == VirtualKeyCode.VK_RIGHT)
            {
                VirtualKeyboard.KeyDown(VirtualKeyCode.VK_ESCAPE);
                VirtualKeyboard.KeyUp(VirtualKeyCode.VK_ESCAPE);
                await Task.Delay(delay);
            }
        }
Beispiel #2
0
        public static async Task SnapCurrentWindowClean(SnappingDirection dir, int delay = SNAPPING_DELAY)
        {
            VirtualKeyCode key = VirtualKeyCode.VK_LEFT;

            switch (dir)
            {
            case SnappingDirection.LEFT:
                key = VirtualKeyCode.VK_LEFT;
                break;

            case SnappingDirection.RIGHT:
                key = VirtualKeyCode.VK_RIGHT;
                break;

            case SnappingDirection.TOP:
                key = VirtualKeyCode.VK_UP;
                break;

            case SnappingDirection.BOTTOM:
                key = VirtualKeyCode.VK_DOWN;
                break;
            }

            VirtualKeyboard.KeyDown(VirtualKeyCode.VK_LWIN);
            VirtualKeyboard.KeyDown(key);
            VirtualKeyboard.KeyUp(key);
            VirtualKeyboard.KeyUp(VirtualKeyCode.VK_LWIN);
            await Task.Delay(delay);

            //if left or right, "select window for other side"-tool pops up
            if (dir == SnappingDirection.LEFT || dir == SnappingDirection.RIGHT)
            {
                VirtualKeyboard.KeyDown(VirtualKeyCode.VK_ESCAPE);
                VirtualKeyboard.KeyUp(VirtualKeyCode.VK_ESCAPE);
                await Task.Delay(delay);
            }
        }
 public static void KeyPress(VirtualKeyCode key)
 {
     VirtualKeyboard.KeyDown(key);
     VirtualKeyboard.KeyUp(key);
 }