Example #1
0
        void HotkeyKeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (e.Modifier == KeyModifiers.None) {
                // receiver zone 1
                if (e.Key == Keys.VolumeDown) _conn.SendMessage(new VolumeDown());
                else if (e.Key == Keys.VolumeUp) _conn.SendMessage(new VolumeUp());
            }
            else if (e.Modifier == KeyModifiers.Control) {
                // system volume
                const int APPCOMMAND_VOLUME_UP = 0xA0000;
                const int APPCOMMAND_VOLUME_DOWN = 0x90000;
                const int WM_APPCOMMAND = 0x319;

                if (e.Key == Keys.VolumeDown) SendMessage(new HandleRef(this, Handle), WM_APPCOMMAND, this.Handle, (IntPtr)APPCOMMAND_VOLUME_DOWN);
                else if (e.Key == Keys.VolumeUp) SendMessage(new HandleRef(this, Handle), WM_APPCOMMAND, this.Handle, (IntPtr)APPCOMMAND_VOLUME_UP);
            }
            else if (e.Modifier == (KeyModifiers.Control | KeyModifiers.Alt)) {
                // receiver zone 2
                if (e.Key == Keys.VolumeDown) _conn.SendMessage(new Z2VolumeDown());
                else if (e.Key == Keys.VolumeUp) _conn.SendMessage(new Z2VolumeUp());
            }
            else if (e.Modifier == (KeyModifiers.Control | KeyModifiers.Shift)) {
                // send power toggle
                if (e.Key == Keys.P) _conn.SendMessage(new PowerToggle());
                else if (e.Key == Keys.Q) {
                    _conn.SendMessage(new PowerOff());
                    _conn.Dispose();
                    Disconnect(); // disconnect applet
                    Application.Exit();
                }
            }
        }