无法访问System.Windows.Input下的Keyboard类

sam*_*amy 3 c#

即时通讯工作在一个简单的控制台应用程序,只显示屏幕上的东西.

我遇到了System.Windows.Input类的问题,我只是无法找到它们.

这里的代码我尝试:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace FUAndLOLInstall.LookForAndActivateFile
{
    class KeyboardHandler
    {
        public void usKeyboard()
        {
            System.Windows.Input.Keyboard //its like the class Keyboard not exsit.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

一些信息:我使用librery TestStack.White在windowm上做一些minpultion,我从我的应用程序开始.

TestStack.White本身有一个Keyboard类(White.Core.InputDevices.Keyboard),但这可能是因为这个课让我不能去上课System.Windows.Input.Keyboard吗?

Ree*_*sey 13

由于这是一个控制台应用程序,因此您需要添加一个引用PresentationCore.dll.默认情况下,控制台应用程序中不会引用此程序集.

您可以在以下文档中看到Keyboard:

命名空间:System.Windows.Input

汇编:PresentationCore(在PresentationCore.dll中)

这是主要的WPF程序集之一,默认包含在WPF项目中,但不包括在控制台应用程序中.