samy
samy

Reputation: 1969

can't access Keyboard class under System.Windows.Input

I'm working on a simple console app that just show stuff on the screen.

I got into a problem with System.Windows.Input classes, I just cant get to them.

Here is the code I'm trying:

using System.Windows.Input;

public class KeyboardHandler
{
    public void UseKeyboard() => System.Windows.Input.Keyboard // Its like the class Keyboard not exsit.
}

I'm using a librery TestStack.White to do some manipulation on a window that I start from my application.

TestStack.White itself has a Keyboard class (White.Core.InputDevices.Keyboard), but could it be that this class is stopping me from accessing the System.Windows.Input.Keyboard class?

Upvotes: 4

Views: 12366

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564451

Since this is a Console Application, you'll need to add a reference to PresentationCore.dll. This assembly will not be referenced by default in a Console Application.

You can see this in the documentation for Keyboard:

Namespace: System.Windows.Input

Assembly: PresentationCore (in PresentationCore.dll)

This is one of the main WPF assemblies, and included by default in WPF projects, but not console applications.

Upvotes: 17

Related Questions