WEKF_CustomKey.Remove

Menghapus kombinasi tombol kustom, menyebabkan Filter Keyboard berhenti memblokir kombinasi tombol yang dihapus.

Sintaks

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

Parameter

CustomKey
[in] Kombinasi kunci kustom yang akan dihapus.

Tampilkan Nilai

Mengembalikan nilai HRESULT yang menunjukkan status WMI atau kesalahan WMI.

Keterangan

WEKF_CustomKey.Remove menghapus objek WEKF_CustomKey yang ada. Jika objek tidak ada, WEKF_CustomKey.Remove mengembalikan kesalahan dengan nilai 0x8007007B.

Karena metode ini statis, Anda tidak dapat memanggilnya pada instans objek, tetapi harus memanggilnya di tingkat kelas.

Contoh

Kode berikut menunjukkan cara menghapus kunci kustom dari Filter Keyboard sehingga tidak lagi diblokir dengan menggunakan penyedia Windows Management Instrumentation (WMI) untuk Filter Keyboard.

$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);
    }
}

Persyaratan

Edisi Windows Didukung
Windows Home Tidak
Windows Pro Tidak
Windows Enterprise Ya
Windows Education Ya
Windows IoT Enterprise Ya