SendKeys 无法识别而应存在于上下文中

SendKeys not recognize while should exist in context

我想将 SendKeys 发送到 c# 中的进程。我添加了System.Windows.Forms,然后出现了这个错误:

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.

我确实为 System.Drawing 添加了参考,但现在对于 SendKeys 我得到:

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

我在Visual studio中打开了Object browserSendKeys存在:

public class SendKeys
    Member of System.Windows.Forms

Summary:
Provides methods for sending keystrokes to an application.

我错过了什么?

您需要在代码顶部添加 using System.Windows.Forms,或者在使用 SendKeys 时直接使用命名空间:System.Windows.Forms.SendKeys