Beispiel #1
0
 public static void change_volume(int delta)
 {
     if (delta > 0)
     {
         VirtualMedia.volume_up();
     }
     else if (delta < 0)
     {
         VirtualMedia.volume_down();
     }
 }
Beispiel #2
0
        public Action(string action_string, string label)
        {
            this._action_string = action_string;
            this.label          = label;

            // parse action string

            // simple keys
            // modifiers: shift = +, ctrl = ^, alt = %
            Match m = Regex.Match(action_string, @"^([+%^]*)(.|\{(BKSP|CAPSLOCK|DEL|DOWN|END|ENTER|ESC|HOME|INS|LEFT|NUMLOCK|PGDN|PGUP|PRTSC|RIGHT|TAB|UP|F\d+)\})$", RegexOptions.IgnoreCase);

            if (m.Success)
            {
                _act = (x) => SendKeys.SendWait(action_string);
            }

            // virtual keyboard
            m = Regex.Match(action_string, @"^osk$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => invoke_osk();
            }

            // wheel rotation (vertical and horizontal scrolling)
            m = Regex.Match(action_string, @"^wheel$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMouse.Wheel(get_wheel_deltaX(x), get_wheel_deltaY(x));
            }

            // mouse movement
            m = Regex.Match(action_string, @"^mouse$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMouse.Move(get_mouse_deltaX(x), get_mouse_deltaY(x));
            }

            // mouse buttons
            m = Regex.Match(action_string, @"^mouse left$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMouse.LeftClick();
            }
            m = Regex.Match(action_string, @"^mouse right$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMouse.RightClick();
            }
            m = Regex.Match(action_string, @"^mouse middle", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMouse.MiddleClick();
            }

            // volume
            m = Regex.Match(action_string, @"^volume$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                _act = (x) => VirtualMedia.change_volume(get_volume_delta(x));
            }
        }