WEKF_PredefinedKey

此類別會封鎖或解除封鎖預先定義的按鍵組合,例如 Ctrl+Alt+Delete。

語法

class WEKF_PredefinedKey {
    [Static] uint32 Enable (
        [In] string PredefinedKey
    );
    [Static] uint32 Disable (
        [In] string PredefinedKey
    );

    [Key] string Id;
    [Read, Write] boolean Enabled;
};

成員

下表列出屬於這個類別的任何建構函式、方法、欄位和屬性。

方法

方法 描述
WEKF_PredefinedKey.Enable 封鎖指定的預先定義索引鍵。
WEKF_PredefinedKey.Disable 解除封鎖指定的預先定義索引鍵。

屬性

屬性 資料類型 限定詞 描述
識別碼 string [key] 預先定義的按鍵組合名稱。
Enabled Boolean [read, write] 指出金鑰是被封鎖還是解除封鎖。 若要指出已封鎖金鑰,請指定 true。 若要指出索引鍵未遭到封鎖,請指定 false

備註

所有帳戶都有 WEKF_PRedefinedKey 類別的讀取權限,但只有系統管理員帳戶可以修改 類別。

如需鍵盤篩選預先定義的按鍵組合清單,請參閱 預先定義的按鍵組合

範例

下列範例Windows PowerShell腳本會在鍵盤篩選服務執行時封鎖 Ctrl+Alt+Delete 和 Ctrl+Esc 鍵組合。

<#
.Synopsis
    This script shows how to use the built in WMI providers to enable and add 
    Keyboard Filter rules through Windows PowerShell on the local computer.
.Parameter ComputerName
    Optional parameter to specify a remote machine that this script should
    manage.  If not specified, the script will execute all WMI operations
    locally.
#>
param (
    [String] $ComputerName
)

$CommonParams = @{"namespace"="root\standardcimv2\embedded"}
$CommonParams += $PSBoundParameters

function Enable-Predefined-Key($Id) {
    <#
    .Synposis
        Toggle on a Predefined Key Keyboard Filter Rule
    .Description
        Use Get-WMIObject to enumerate all WEKF_PredefinedKey instances,
        filter against key value "Id", and set that instance's "Enabled"
        property to 1/true.
    .Example
        Enable-Predefined-Key "Ctrl+Alt+Delete"

        Enable CAD filtering
#>

    $predefined = Get-WMIObject -class WEKF_PredefinedKey @CommonParams |
        where {
            $_.Id -eq "$Id"
        };

    if ($predefined) {
        $predefined.Enabled = 1;
        $predefined.Put() | Out-Null;
        Write-Host Enabled $Id
    } else {
        Write-Error $Id is not a valid predefined key
    }
}

# Some example uses of the function defined above.

Enable-Predefined-Key "Ctrl+Alt+Delete"
Enable-Predefined-Key "Ctrl+Esc"

規格需求

Windows 版本 支援
Windows 首頁 No
Windows 專業版
Windows 企業版
Windows 教育版
Windows IoT 企業版 是的

鍵盤篩選器 WMI 提供者參考資料

鍵盤篩選器