Skip to content

Add a simple command

Overview

To create a simple command, add to your plugin project a class inherited from the PluginDynamicCommand class. To alter the command appearance and behavior, change the properties and overwrite the virtual methods of this class.

As an example, let's add a simple command to the Demo plugin that mutes and unmutes the system sound. You can assign this command to a touch or a physical button on a console.

To toggle between mute and unmute, we send the VK_VOLUME_MUTE virtual-key code using one of the native methods provided by the Loupedeck Plugin API that works on both Windows and macOS.

The full source code for this topic is at: DemoPlugin/Step03

You can find the ToggleMuteCommand class here: ToggleMuteCommand.cs

Steps

  1. Open the Demo plugin solution in Visual Studio.

  2. In the Solution Explorer, right-click on the DemoPlugin project and select Add > Class.

  3. Enter ToggleMuteCommand.cs as the file name and click Add. The ToggleMuteCommand class opens for editing.

  4. Inherit the ToggleMuteCommand class from the PluginDynamicCommand class:

    class ToggleMuteCommand : PluginDynamicCommand
    
  5. Create an empty, parameterless constructor and set the command display name, description, and group name in the parent constructor parameters:

    public ToggleMuteCommand()
        : base(displayName: "Toggle Mute", description: "Toggles audio mute state", groupName: "Audio")
    {
    }
    
  6. Overwrite the RunCommand method that is called every time a user presses the touch or the physical button to which this command is assigned:

    protected override void RunCommand(String actionParameter)
    {
        this.Plugin.ClientApplication.SendKeyboardShortcut(VirtualKeyCode.VolumeMute);
    }
    
  7. Start debugging and wait until the software is loaded.

  8. Open the configuration UI.

  9. Switch the Adapt to App to OFF Options+ or Dynamic mode to OFF in Loupedeck Software.

  10. In the applications dropdown list, select Demo.

  11. On the left pane, under Press Actions, expand the Demo node, then expand the Audio group and ensure that the Toggle Mute command is there.

  12. Drag and drop the Toggle Mute command to any touch button.

  13. Connect a console to your computer.

  14. Check that the console shows the Toggle Mute command on the touch screen.

  15. Press this button to mute and unmute your computer's audio.