WEKF _ CustomKey。移除WEKF_CustomKey.Remove

移除自訂按鍵組合,導致鍵盤篩選停止封鎖移除的按鍵組合。Removes a custom key combination, causing Keyboard Filter to stop blocking the removed key combination.

語法Syntax

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

參數Parameters

CustomKey []要移除的自訂按鍵組合。CustomKey [in] The custom key combination to remove.

傳回值Return Value

傳回 HRESULT 值,指出 wmi 狀態wmi 錯誤Returns an HRESULT value that indicates WMI status or a WMI error.

備註Remarks

WEKF _CustomKey 移除現有的 WEKF _ CustomKey 物件。WEKF_CustomKey.Remove removes an existing WEKF_CustomKey object. 如果物件不存在, WEKF _ CustomKey。 Remove 會傳回值0x8007007B 的錯誤。If the object does not exist, WEKF_CustomKey.Remove returns an error with the value 0x8007007B.

因為這個方法是靜態的,所以您無法在物件實例上呼叫它,而是必須在類別層級呼叫它。Because this method is static, you cannot call it on an object instance, but must instead call it at the class level.

範例Example

下列程式碼示範如何從鍵盤篩選移除自訂金鑰,如此就不會再使用鍵盤篩選的 Windows Management Instrumentation (WMI) 提供者來封鎖它。The following code demonstrates how to remove a custom key from Keyboard Filter so it is no longer blocked by using the Windows Management Instrumentation (WMI) providers for Keyboard Filter.

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

需求Requirements

Windows 版本Windows Edition 支援Supported
Windows 10 HomeWindows 10 Home No
Windows 10 ProWindows 10 Pro No
Windows 10 EnterpriseWindows 10 Enterprise Yes
Windows 10 EducationWindows 10 Education Yes

WEKF _ CustomKeyWEKF_CustomKey

鍵盤篩選器Keyboard Filter