WEKF_CustomKey.Remove

Supprime une combinaison de touches personnalisée, ce qui entraîne l’arrêt du filtre clavier pour bloquer la combinaison de touches supprimée.

Syntaxe

[Static] uint32 Remove(
    [In] string CustomKey
);

Paramètres

CustomKey
[in] Combinaison de touches personnalisées à supprimer.

Valeur renvoyée

Retourne une valeur HRESULT qui indique l’état de WMI ou une erreur WMI.

Remarques

WEKF_CustomKey.Remove supprime un objet WEKF_CustomKey existant. Si l’objet n’existe pas, WEKF_CustomKey.Remove retourne une erreur avec la valeur 0x8007007B.

Étant donné que cette méthode est statique, vous ne pouvez pas l’appeler sur une instance d’objet, mais vous devez l’appeler au niveau de la classe.

Exemple

Le code suivant montre comment supprimer une touche personnalisée du filtre clavier pour qu’elle ne soit plus bloquée à l’aide des fournisseurs WMI (Windows Management Instrumentation) pour le filtre clavier.

$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"

# Create a handle to the class instance so we can call the static methods
$classCustomKey = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WEKF_CustomKey"

# Create a function to remove a key combination
function Remove-Custom-Key($KeyId) {

# Call the static Remove() method on the class reference
    $retval = $classCustomKey.Remove($KeyId)

# Check the return value for status
    if ($retval.ReturnValue -eq 0) {

# Custom key combination removed successfully
        "Removed ${KeyID}."
    } elseif ($retval.ReturnValue -eq 2147942523) {

# No object exists with the specified custom key
        "Failed to remove ${KeyID}. No object found."
    } else {

# Unknown error, report error code in hexadecimal
        "Failed to remove ${KeyID}. Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
    }
}


# Example of removing a custom key so that Keyboard Filter stops blocking it
Remove-Custom-Key "Ctrl+Alt+w"

# Example of removing all custom keys that have the Enabled property set to false
$objDisabledCustomKeys = Get-WmiObject -Namespace $NAMESPACE -Class WEKF_CustomKey;

foreach ($objCustomKey in $objDisabledCustomKeys) {
    if (!$objCustomKey.Enabled) {
        Remove-Custom-Key($objCustomKey.Id);
    }
}

Configuration requise

Édition Windows Prise en charge
Windows Famille Non
Windows Pro Non
Windows Entreprise Oui
Windows Éducation Oui
Windows IoT Entreprise Oui