The name 'Helper' does not exist in the current context

六月ゝ 毕业季﹏ 提交于 2019-12-13 10:08:53

问题


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

This is my current code:

 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;
    }
}

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.

What exactly is 'Helper' and how do I fix this error?


回答1:


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.



来源:https://stackoverflow.com/questions/31953297/the-name-helper-does-not-exist-in-the-current-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!