我无法编辑"A在当前上下文中不存在名称"A". [英] I can't edit " A The name 'A' does not exist in the current context "

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

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Diagnostics;
using System.Data;
namespace ConsoleApplication1
{
    class Program
    {
        globalKeyboardHook gkh = new globalKeyboardHook();
        
        public void Form1_Load()
        {
            gkh.HookedKeys.Add(Keys.A);
            Console.WriteLine(Keys.A);
            gkh.KeyUp += new KeyEventHandler(gkh_KeyUp);            
        }

        public void gkh_KeyUp(object sender, KeyEventArgs e)
        {            
           Console.WriteLine(Keys.A);
           if (e.KeyCode== Keys.A)
           {
                Process.Start("System.exe");
           }                
        }
    }
        
    class on
    {
        static void Main(string[] args)
        {               
           Program nesne = new Program();
           nesne.Form1_Load();
           nesne.gkh_KeyUp(null,null);
        }
    }
}


nesne.gkh_KeyUp(null,null); ->我的错
+编译器说"A名称"A"在当前上下文中不存在"

我想按"A",我的系统必须正常运行,另外我不想使用Form,我不想看到Form窗口.当我看到命令窗口(黑屏)时,我必须按"A"并且它必须起作用.我想做不同的快捷键.不经典

帮助 !!!我必须更改(null,null),但我不知道.我该怎么写?


nesne.gkh_KeyUp(null,null); --> my wrong
+ compiler said "A The name ''A'' does not exist in the current context"

I want to press "A" and my system must working in addition I dont want to use Form ,I dont want to see Form window. When ı see command window(black screen),I must press "A" and it must work. I want to do diffrent shortcut key. Not classic

HELP !!! I must change (null,null) but I dont know. What can I write?

推荐答案

这样您就可以了

so you ran

nesne.gkh_KeyUp(null,null);


您希望它能正常工作吗?.

它会到达if (e.KeyCode== Keys.A)并且将会失败,因为e为空.您是否要向程序发送"A"键代码以启动?如果是这样,则需要创建一个新的KeyEventArgs


and you expect that to work?.

It''s going to get to if (e.KeyCode== Keys.A) and it''s going to fail because e is null. Are you trying to send a "A" keycode to the program to start? If so, you need to create a new KeyEventArgs

System.Windows.Forms.KeyEventArgs myArgs = new 
         System.Windows.Forms.KeyEventArgs(System.Windows.Forms.Keys.A)



并将其作为第二个参数传递.



and pass that in as the second argument.


如果我写了您的实际建议,则我的system.exe在工作,但我不这样做.我想按"A",我的系统必须正常工作,此外,我不想使用Form,也不想看到Form窗口.当我看到命令窗口(黑屏)时,我必须按"A"并且它必须起作用.我想做不同的快捷键.不经典
if ı write your practical proposal,my system.exe is working but ı dont it. I want to press "A" and my system must working, in addition I dont want to use Form ,I dont want to see Form window. When ı see command window(black screen),I must press "A" and it must work. I want to do diffrent shortcut key. Not classic


这篇关于我无法编辑"A在当前上下文中不存在名称"A".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆