当前上下文中不存在名称

当前上下文中不存在名称

本文介绍了当前上下文中不存在名称“ Helper”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#应用程序中,我按照T Perquin的建议

In my C# application, I am using a MessageFilter for a global key hook as suggested by T Perquin.

这是我当前的代码:

 class KeyboardMessageFilter : IMessageFilter
{
    public bool PreFilterMessage(ref Message m)
    {
        if (m.Msg == ((int)Helper.WindowsMessages.WM_KEYDOWN))
        {
            switch ((int)m.WParam)
            {
                case (int)Keys.Escape:
                    // Do Something
                    return true;
                case (int)Keys.Right:
                    // Do Something
                    return true;
                case (int)Keys.Left:
                    // Do Something
                    return true;
            }
        }

        return false;
    }
}

当我尝试编译并运行(以确保语法正确),我会收到以下错误消息:
名称 Helper在当前上下文中不存在

When I try to compile and run (to make sure the syntax's are correct), I get this error:
The name 'Helper' does not exist in the current context.

帮助程序到底是什么?如何解决此错误?

推荐答案

看起来 Helper 是一个包含静态或常量变量的类,例如Windows消息 WM_KEYDOWN 。由于只使用它,因此可以将其添加到文件中。

It looks like Helper is a class that contains static or constant variables like the Windows Message WM_KEYDOWN. Since you are only using that you can add it in your file.

const int WM_KEYDOWN = 0x100;

以下是其他,以备不时之需。

Here are the other Keyboard Input Notifications, in case you need it.

这篇关于当前上下文中不存在名称“ Helper”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 08:31