Delphi でマルチメディア キー (再生/一時停止、前/次のトラック、巻き戻し/進むなど) の押下をシミュレートする必要があります。次のコードを使用して、「通常の」キーを簡単にシミュレートできます。
keybd_event(VK_SPACE,0, 0, 0);
keybd_event(VK_SPACE,0, KEYEVENTF_KEYUP, 0);
また、MAKE/BREAK コードの一覧を見つけたのですが、どうすればよいですか?
MSDN は次のように述べています。
VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);
bVk - Specifies a virtual-key code. The code must be a value in the range 1 to 254.
bScan - Specifies a hardware scan code for the key.
dwFlags - A set of flag bits that specify various aspects of function operation.
An application can use any combination of the following predefined constant
values to set the flags:
KEYEVENTF_EXTENDEDKEY - If specified, the scan code was preceded by a
prefix byte having the value 0xE0 (224).
KEYEVENTF_KEYUP If specified, the key is being released. If
not specified, the key is being depressed.
dwExtraInfo - Specifies an additional 32-bit value associated with the key stroke.
ボリュームアップのスキャンコードを見つけました:
メイクコード:E0、32 ブレークコード:E0、F0、32
私は試した:
keybd_event(0,$32, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(0,$32, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
しかし運もありません (これは F0 なしで E0 32 E0 32 をシミュレートする必要があります)。また、MSDN によると、bVk は [1..254] でなければなりません。キー コード リストに適切なものが見つからなかったため、0 を使用しました。