本文整理汇总了C#中Keyboard.SetCooperativeLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Keyboard.SetCooperativeLevel方法的具体用法?C# Keyboard.SetCooperativeLevel怎么用?C# Keyboard.SetCooperativeLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keyboard
的用法示例。
在下文中一共展示了Keyboard.SetCooperativeLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
internal bool Initialize(SystemConfiguration configuration, IntPtr windowsHandle)
{
// Screen the screen size which will be used for positioning the mouse cursor.
_ScreenWidth = configuration.Width;
_ScreenHeight = configuration.Height;
// Initialize the location of the mouse on the screen.
_MouseX = 0;
_MouseY = 0;
// Initialize the main direct input interface.
_DirectInput = new DirectInput();
// Initialize the direct interface for the keyboard.
_Keyboard = new Keyboard(_DirectInput);
_Keyboard.Properties.BufferSize = 256;
// Set the cooperative level of the keyboard to not share with other programs.
_Keyboard.SetCooperativeLevel(windowsHandle, CooperativeLevel.Foreground | CooperativeLevel.Exclusive);
// Now acquire the keyboard.
if (_Keyboard.Acquire().Failure)
return false;
// Initialize the direct interface for the mouse.
_Mouse = new Mouse(_DirectInput);
_Mouse.Properties.AxisMode = DeviceAxisMode.Relative;
// Set the cooperative level of the mouse to share with other programs.
_Mouse.SetCooperativeLevel(windowsHandle, CooperativeLevel.Foreground | CooperativeLevel.NonExclusive);
// Now acquire the mouse.
if (_Mouse.Acquire().Failure)
return false;
return true;
}
示例2: CreateInput
/// <summary> Creates the input manager. </summary>
private void CreateInput(RenderForm window)
{
directInput = new DirectInput();
keyboard = new Keyboard(directInput);
keyboard.SetCooperativeLevel(window.Handle, CooperativeLevel.NonExclusive | CooperativeLevel.Background);
keyboard.Acquire();
}