WEKF_CustomKey.Remove

移除自訂按鍵組合,導致鍵盤篩選停止封鎖移除的按鍵組合。

語法

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

參數

CustomKey [in] 要移除的自訂按鍵組合。

傳回值

傳回 HRESULT 值,指出 WMI 狀態WMI 錯誤

備註

WEKF_CustomKey.Remove 會 移除現有的 WEKF_CustomKey 物件。 如果物件不存在, WEKF_CustomKey.Remove 會傳回值0x8007007B的錯誤。

因為這個方法是靜態的,所以您無法在物件實例上呼叫它,但必須改為在類別層級呼叫它。

範例

下列程式碼示範如何從鍵盤篩選中移除自訂按鍵,因此不再使用鍵盤篩選的 Windows Management Instrumentation (WMI) 提供者加以封鎖。

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

規格需求

Windows 版本 支援
Windows 10 Home
Windows 10 Pro No
Windows 10 Enterprise
Windows 10 Education

WEKF_CustomKey

鍵盤篩選器