UsedCommand Element

Enables a VSPackage to implement its own version of a command that is defined in another .vsct file. For example, if your VSPackage uses the standard Copy command, which is defined by the Visual Studio shell, you can handle the command without redefining it. 

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

guid

Required. The GUID of the GUID ID pair that identifies the command.

id

Required. The ID of the GUID ID pair that identifies the command.

Condition

Optional. See VSCT XML Schema Conditional Attributes.

Child Elements

Element

Description

None

Parent Elements

Element

Description

UsedCommands Element

Groups UsedCommand elements and other UsedCommands groupings.

Remarks

By adding a command to the <UsedCommands> element, a VSPackage informs the Visual Studio environment that although a command is implemented by other code, when the current VSPackage is active, it provides the command implementation. In this case, when any of the windows of the current VSPackage has focus, the current VSPackage's implementations of the QueryStatus and Exec methods take precedence over implementations defined elsewhere. For more information about command routing see Command Routing in VSPackages.

For example, if a VSPackage provides its own support for the Cut, Copy, and Paste commands on the system Edit menu, the commands must be added to the <UsedCommands> element. When any of the windows of the current VSPackage has focus, and a user selects a Cut, Copy, or Paste command, the current VSPackage, and not the Visual Studio shell¸ handles these operations.

Example

<UsedCommands>
  <UsedCommand guid="guidVSStd97" id="cmdidCut"/>
  <UsedCommand guid="guidVSStd97" id="cmdidCopy"/>
  <UsedCommand guid="guidVSStd97" id="cmdidPaste"/>
</UsedCommands>

See Also

Reference

UsedCommands Element

Other Resources

Visual Studio Command Table (.Vsct) Files