WEKF_CustomKey

カスタム定義されたキーの組み合わせを追加または削除します。

構文

class WEKF_CustomKey {
    [Static] uint32 Add(
        [In] string CustomKey
    );
    [Static] uint32 Remove(
        [In] string CustomKey
    );

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

メンバー

次の表に、このクラスに属するメソッドとプロパティを示します。

メソッド

メソッド 説明
WEKF_CustomKey.Add 新しいカスタム キーの組み合わせを作成し、キーボード フィルターで新しいキーの組み合わせをブロックできるようにします。
WEKF_CustomKey.Remove 指定されたカスタムキーの組み合わせを削除します。 キーボードフィルターは削除されたキーの組み合わせの禁止を停止します。

Properties

プロパティ データ型 修飾子 説明
Id string [key] カスタムキーの組み合わせの名前です。
有効 Boolean [read、write] キーが禁止されているか、ブロック解除されているかを示します。 このプロパティは、次のいずれかの値
- を指定できます true キーがブロックされていることを示します。
- False キーがブロックされていないことを示します。

注釈

名前の中に修飾キーを含めることで、キーの組み合わせを指定できます。 最も一般的な修飾子名は、"Ctrl"、"Shift"、"Alt"、および "Win" です。 修飾されていないキーの組み合わせを禁止することはできません。 たとえば、"Ctrl + Shift + F" のキーの組み合わせをブロックすることはできますが、"A + D" のキーの組み合わせをブロックすることはできません。

シフト変更キーをブロックする場合は、キーを "Shift" + 変更されていないキーとして入力する必要があります。 たとえば、英語のキーボード レイアウトで % キーをブロックするには、キーを "Shift + 5" として指定する必要があります。 "%" をブロックしようとすると、代わりにキーボード フィルターによって "5" がブロックされます。

禁止するキーの組み合わせを指定する際には、キーの英語名を使用する必要があります。 指定可能なキー名の一覧は、「キーボードフィルタのキー名」を参照してください。

次のコードは、キーボード フィルター用の Windows Management Instrumentation (WMI) プロバイダーを使用して、キーボード フィルターがブロックするカスタム キーを追加または有効にする方法を示しています。 この例では、プロパティを直接変更し、WEKF_CustomKey で定義されているどのメソッドも呼び出しません。

<#
.Synopsis
    This script shows how to use the WMI provider 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-Custom-Key($Id) {
    <#
    .Synopsis
        Toggle on a Custom Key Keyboard Filter Rule
    .Description
        Use Get-WMIObject to enumerate all WEKF_CustomKey instances,
        filter against key value "Id", and set that instance's "Enabled"
        property to 1/true.

        In the case that the Custom instance does not exist, add a new
        instance of WEKF_CustomKey using Set-WMIInstance.
    .Example
        Enable-Custom-Key "Ctrl+V"

        Enable filtering of the Ctrl + V sequence.
#>

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

    if ($custom) {
# Rule exists.  Just enable it.
        $custom.Enabled = 1;
        $custom.Put() | Out-Null;
        "Enabled Custom Filter $Id.";

    } else {
        Set-WMIInstance `
            -class WEKF_CustomKey `
            -argument @{Id="$Id"} `
            @CommonParams | Out-Null

        "Added Custom Filter $Id.";
    }
}


# Some example uses of the function defined above.

Enable-Custom-Key "Ctrl+V"
Enable-Custom-Key "Numpad0"
Enable-Custom-Key "Shift+Numpad1"

要件

Windows エディション サポートされています
Windows ホーム いいえ
Windows Pro いいえ
Windows Enterprise はい
Windows Education はい
Windows IoT Enterprise はい

キーボード フィルター WMI プロバイダー リファレンス

キーボード フィルターのキー名