0

RegisterHotKeyを使用できるようにするために使用する必要がある参照をGoogleで見つけることができません。それは何ですか?

バックグラウンドでキーの組み合わせをリッスンするアプリケーションを作成しようとしている場合は、RegisterHotKey を使用する必要がありますか?

4

2 に答える 2

3

参照だけでなく、が必要ですDllImportpinvoke.net でさらに多くの情報を見つけることができます。

つまり、次を追加すると:

[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);

プログラムのどこかで、残りのトリッキーな部分はhWnd、キーを処理するために登録することです。上記の pinvoke.net にリンクされているサンプル コードは、DllImport.

于 2012-01-07T06:09:54.923 に答える
1

C# から RegisterHotKey 関数を使用するために必要なものは次のとおりです。

/// <summary> The RegisterHotKey function defines a system-wide hot key </summary>
/// <param name="hwnd">Handle to the window that will receive WM_HOTKEY messages generated by the hot key.</param>
/// <param name="id">Specifies the identifier of the hot key.</param>
/// <param name="fsModifiers">Specifies keys that must be pressed in combination with the key specified by the 'vk' parameter in order to generate the WM_HOTKEY message.</param>
/// <param name="vk">Specifies the virtual-key code of the hot key</param>
/// <returns><c>true</c> if the function succeeds, otherwise <c>false</c></returns>
/// <seealso cref="http://msdn.microsoft.com/en-us/library/ms646309(VS.85).aspx"/>
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
于 2012-01-07T06:12:01.197 に答える