次の方法で共有


WEKF_CustomKey

サポートされているエディション
✅ IoT Enterprise LTSC
✅ IoT Enterprise
✅ Enterprise LTSC
✅ Enterprise
✅ Education

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

構文

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

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

Members

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

メソッド

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

プロパティ

プロパティ データ型 修飾子 説明
Id 文字列 [キー] カスタム キーの組み合わせの名前。
Enabled ブール値 [読み取り、書き込み] キーがブロックされているかブロック解除されているかを示します。 このプロパティは、次のいずれかの値を指定できます
- true キーがブロックされていることを示します
- キーがブロックされていないことを示します。

注釈

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

>Shift で変更されたキーをブロックする場合は、キーを >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"

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

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