Search code examples
c#visual-studiosendkeys

SendKeys not recognize while should exist in context


I want to send a SendKeys to a process in c#. I added System.Windows.Forms, I had this error then:

C:\Users\user\Desktop\Project\Project\Workflow1.xaml : error XC1014: Assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' can not be resolved. Please add a reference to this assembly in the project that is being built.

I did add reference for System.Drawing, but now for SendKeys I get:

The name 'SendKeys' does not exist in the current context.

I opened up the Object browser in Visual studio, and SendKeys is existing :

public class SendKeys
    Member of System.Windows.Forms

Summary:
Provides methods for sending keystrokes to an application.

What am I missing?


Solution

  • You need to either add using System.Windows.Forms on top of your code, or directly use the namespace when using SendKeys: System.Windows.Forms.SendKeys