当前位置: 首页>>代码示例>>C#>>正文


C# Keyboard.SetCooperativeLevel方法代码示例

本文整理汇总了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;
        }
开发者ID:nyx1220,项目名称:sharpdx-examples,代码行数:37,代码来源:Input.cs

示例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();
 }
开发者ID:TomCrypto,项目名称:Insight,代码行数:8,代码来源:Scene.cs


注:本文中的Keyboard.SetCooperativeLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。