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
-
Open the Demo plugin solution in Visual Studio.
-
In the Solution Explorer, right-click on the DemoPlugin project and select Add > Class.
-
Enter ToggleMuteCommand.cs as the file name and click Add. The
ToggleMuteCommand
class opens for editing. -
Inherit the
ToggleMuteCommand
class from thePluginDynamicCommand
class: -
Create an empty, parameterless constructor and set the command display name, description, and group name in the parent constructor parameters:
-
Overwrite the
RunCommand
method that is called every time a user presses the touch or the physical button to which this command is assigned: -
Start debugging and wait until the software is loaded.
-
Open the configuration UI.
-
Switch the Adapt to App to OFF Options+ or Dynamic mode to OFF in Loupedeck Software.
-
In the applications dropdown list, select Demo.
-
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.
-
Drag and drop the Toggle Mute command to any touch button.
-
Connect a console to your computer.
-
Check that the console shows the Toggle Mute command on the touch screen.
-
Press this button to mute and unmute your computer's audio.