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 取消阻止指定的预定义键。

属性

属性 数据类型 限定符 说明
Id string [键] 预定义组合键的名称。
已启用 Boolean [读,写] 指示是阻止还是取消阻止键。 若要指示阻止键,请指定 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 主页
Windows 专业版
Windows 企业版
Windows 教育版
Windows IoT 企业版 是的

键盘筛选器 WMI 提供程序参考

键盘筛选器