Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# e> 长度>=1,相当于.Any()@dialogicus从现在开始,我会一直这样做,因为这只是我犯下的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释问题+1:)哦,这似乎有效,提前谢谢!)为什么它会这样回来?我有3个记事本进程,所以基本上_C# - Fatal编程技术网

C# e> 长度>=1,相当于.Any()@dialogicus从现在开始,我会一直这样做,因为这只是我犯下的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释问题+1:)哦,这似乎有效,提前谢谢!)为什么它会这样回来?我有3个记事本进程,所以基本上

C# e> 长度>=1,相当于.Any()@dialogicus从现在开始,我会一直这样做,因为这只是我犯下的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释问题+1:)哦,这似乎有效,提前谢谢!)为什么它会这样回来?我有3个记事本进程,所以基本上,c#,C#,e> 长度>=1,相当于.Any()@dialogicus从现在开始,我会一直这样做,因为这只是我犯下的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释问题+1:)哦,这似乎有效,提前谢谢!)为什么它会这样回来?我有3个记事本进程,所以基本上应该是真的,我对O感到困惑。o@TuukkaX一步一步地调试代码,并找到一个代码所做的事情与您期望的不同的地方。然后告诉我们它在什么地方,你期望什么,它到底发生了什么,然后我们可以更好地解释给你听。@TuukkaX读第一句话。您的代码仅在(no


e> 长度>=1,相当于
.Any()
@dialogicus从现在开始,我会一直这样做,因为这只是我犯下的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释问题+1:)哦,这似乎有效,提前谢谢!)为什么它会这样回来?我有3个记事本进程,所以基本上应该是真的,我对O感到困惑。o@TuukkaX一步一步地调试代码,并找到一个代码所做的事情与您期望的不同的地方。然后告诉我们它在什么地方,你期望什么,它到底发生了什么,然后我们可以更好地解释给你听。@TuukkaX读第一句话。您的代码仅在(notes.Length<1)或“没有记事本运行时”执行。你想把它转换成
Length>=1
,这相当于
.Any()
@dialogicus从现在开始,我每次都会这样做,因为这只是我犯的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释这个问题+1:)哦,这似乎行得通,提前谢谢!:)为什么它会这样回来?我有3个记事本进程,所以基本上应该是真的,我对O感到困惑。o@TuukkaX一步一步地调试代码,并找到一个代码所做的事情与您期望的不同的地方。然后告诉我们它在什么地方,你期望什么,它到底发生了什么,然后我们可以更好地解释给你听。@TuukkaX读第一句话。您的代码仅在(notes.Length<1)或“没有记事本运行时”执行。你想把它转换成
Length>=1
,这相当于
.Any()
@dialogicus从现在开始,我每次都会这样做,因为这只是我犯的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释这个问题+1:)哦,这似乎行得通,提前谢谢!:)为什么它会这样回来?我有3个记事本进程,所以基本上应该是真的,我对O感到困惑。o@TuukkaX一步一步地调试代码,并找到一个代码所做的事情与您期望的不同的地方。然后告诉我们它在什么地方,你期望什么,它到底发生了什么,然后我们可以更好地解释给你听。@TuukkaX读第一句话。您的代码仅在(notes.Length<1)或“没有记事本运行时”执行。你想把它转换成
Length>=1
,这相当于
.Any()
@dialogicus从现在开始,我会一直这样做,因为这只是我犯的一个愚蠢的小错误,我没有注意到:D感谢CodeCaster解释这个问题+1:)
delegate void WriteText(Process[] notepads, bool WriteAll, int index);

    [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    [DllImport("User32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
    static void Main(params string[] args)
    {
        if (args.Length != 0)
        {
            if (args != null)
            {
                string fullStr = "";
                foreach (string str in args)
                {
                    fullStr += str + " ";
                }
                int index = 0;
                WriteToNotepad(fullStr, ref index);
                Thread.Sleep(500);
                Console.WriteLine(string.Format("Wrote ' {0} ' to notepad[ {1} ] !", fullStr, index));

                Console.ReadLine();
            }
        }
    }

    static void WriteToNotepad(string text, ref int chosenNotepad)
    {
        WriteText write = (Process[] notepads, bool WriteAll, int index) =>
            {
                if (!WriteAll)
                {
                    if (notepads.Length == 0) return;
                    if (notepads[index] != null)
                    {
                        IntPtr child = FindWindowEx(notepads[index].MainWindowHandle, new IntPtr(0), "Edit", null);
                        SendMessage(child, 0x000c, 0, text);
                    }
                }
                else
                {
                    for (int notepadIndex = 0; notepadIndex < notepads.Length; notepadIndex++)
                    {
                        IntPtr child = FindWindowEx(notepads[notepadIndex].MainWindowHandle, new IntPtr(0), "Edit", null);
                        SendMessage(child, 0x000c, 0, text);
                    }
                }
            };

        Process[] notes = Process.GetProcessesByName("notepad");

        if (notes.Length < 1)
        {
            for (int i = 0; i < notes.Length; i++)
            {
                Console.WriteLine(string.Format("{0}: {1}", i, notes[i].Id));
            }
            Console.WriteLine("\nPick a number to select which notepad to edit.\nEnter 'ALL' to modify memory of every notepad process active:  ");
            string answer = Console.ReadLine();
            if (answer == "ALL")
            {
                write(notes, true, 0);
            }
            else
            {
                try
                {
                    int ans = Convert.ToInt32(answer);
                    chosenNotepad = ans;
                    write(notes, false, Convert.ToInt32(ans));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("\n\n\n" + ex.Message);
                }
            }
        }
    }