title: How can i SendMessage to other processes windows then notepad?
body: <p>In the top of form1</p>
  
  <pre><code>const int WM_SETTEXT = 0X000C;
  
          //include FindWindowEx
          [DllImport("user32.dll")]
          public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  
          //include SendMessage
          [DllImport("user32.dll")]
          public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
  </code></pre>
  
  <p>Then in the constructor</p>
  
  <pre><code>//getting notepad's process | at least one instance of notepad must be running
              Process notepadProccess = Process.GetProcessesByName("devenv")[0];
  
              //getting notepad's textbox handle from the main window's handle
              //the textbox is called 'Edit'
              IntPtr notepadTextbox = FindWindowEx(notepadProccess.MainWindowHandle, IntPtr.Zero, "Edit", null);
              //sending the message to the textbox
              SendMessage(notepadTextbox, WM_SETTEXT, 0, "Testing");
  </code></pre>
  
  <p>This is working for the notepad.
  But if i want to send a message to another visual studio opened window of a project ? </p>
  
  <p>For example i created a new project in a new visual studio and created in the project a new class called it test
  And i want to send to the class some text for example:</p>
  
  <pre><code>using system;
  </code></pre>
  
  <p>For example this is the new class window:</p>
  
  <p><a href="https://i.stack.imgur.com/p9AAI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p9AAI.jpg" alt="test"></a></p>
  
  <p>After sending the message it will be like this:</p>
  
  <p><a href="https://i.stack.imgur.com/H45fE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H45fE.jpg" alt="test"></a></p>