WEKF_CustomKey.Add
Ediciones admitidas
✅ IoT Enterprise LTSC
✅ IoT Enterprise
✅ LTSC✅
Enterprise
✅ Education
Crea una nueva combinación de teclas personalizada y permite que Filtro de teclado bloquee la nueva combinación de teclas.
Sintaxis
[Static] uint32 Add(
[In] string CustomKey
);
Parámetros
CustomKey
[in] Combinación de teclas personalizada que se va a agregar. Para obtener una lista de nombres de clave válidos, consulte Nombres de teclas de filtro de teclado.
Valor devuelto
Devuelve un valor HRESULT que indica una constante wmi que no es de error o una constante de error WMI.
Observaciones
WEKF_CustomKey.Add crea un nuevo objeto WEKF_CustomKey y establece la propiedad Enabled del nuevo objeto en true y la propiedad Id en CustomKey.
Si ya existe un objeto WEKF_CustomKey con la propiedad Id igual a CustomKey, WEKF_CustomKey.Add devuelve un código de error y no crea un nuevo objeto ni modifica ninguna propiedad del objeto existente. Si el objeto WEKF_CustomKey existente tiene la propiedad Enabled establecida en false, Filtro de teclado no bloquea la combinación de teclas personalizada.
Por ejemplo:
En el código siguiente se muestra cómo agregar o habilitar una tecla personalizada que el filtro de teclado bloqueará mediante los proveedores de Instrumental de administración de Windows (WMI) para el filtro de teclado.
$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 add or enable a key combination for Keyboard Filter to block
function Enable-Custom-Key($KeyId) {
# Check to see if the custom key object already exists
$objCustomKey = Get-WMIObject -namespace $NAMESPACE -class WEKF_CustomKey |
where {$_.Id -eq "$KeyId"};
if ($objCustomKey) {
# The custom key already exists, so just enable it
$objCustomKey.Enabled = 1;
$objCustomKey.Put() | Out-Null;
"Enabled ${KeyId}.";
} else {
# Create a new custom key object by calling the static Add method
$retval = $classCustomKey.Add($KeyId);
# Check the return value to verify that the Add is successful
if ($retval.ReturnValue -eq 0) {
"Added ${KeyID}."
} else {
"Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
}
}
}
# Enable Keyboard Filter to block several custom keys
Enable-Custom-Key "Ctrl+v"
Enable-Custom-Key "Ctrl+v"
Enable-Custom-Key "Shift+4"
Enable-Custom-Key "Ctrl+Alt+w"
# List all the currently existing custom keys
$objCustomKeyList = get-WMIObject -namespace $NAMESPACE -class WEKF_CustomKey
foreach ($objCustomKeyItem in $objCustomKeyList) {
"Custom key: " + $objCustomKeyItem.Id
" enabled: " + $objCustomKeyItem.Enabled
}