WEKF_CustomKey.Add
Edizioni
✅ supportate IoT Enterprise LTSC
✅ IoT Enterprise
✅ LTSC✅
Enterprise
✅ Education
Crea una nuova combinazione di tasti personalizzata e consente a Filtro tastiera di bloccare la nuova combinazione di tasti.
Sintassi
[Static] uint32 Add(
[In] string CustomKey
);
Parametri
CustomKey
[in] Combinazione di tasti personalizzata da aggiungere. Per un elenco di nomi di tasti validi, vedere Nomi dei tasti di filtro della tastiera.
Valore restituito
Restituisce un valore HRESULT che indica una costante WMI non error o una costante di errore WMI.
Osservazioni
WEKF_CustomKey.Add crea un nuovo oggetto WEKF_CustomKey e imposta la proprietà Enabled del nuovo oggetto su true e la proprietà Id su CustomKey.
Se esiste già un oggetto WEKF_CustomKey con la proprietà Id uguale a CustomKey, WEKF_CustomKey.Add restituisce un codice di errore e non crea un nuovo oggetto né modifica le proprietà dell'oggetto esistente. Se la proprietà Enabled dell'oggetto WEKF_CustomKey esistente è impostata su false, Filtro tastiera non blocca la combinazione di tasti personalizzata.
Esempio
Il codice seguente illustra come aggiungere o abilitare un tasto personalizzato che il filtro tastiera bloccherà usando i provider di Strumentazione gestione Windows (WMI) per filtro tastiera.
$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
}