Process[] processlist = Process.GetProcesses();
List<string> names = new List<string>();
foreach (Process process in processlist)
{
if (!String.IsNullOrEmpty(process.MainWindowTitle))
{
if (process.MainWindowTitle.Contains("GrAD"))
{
CaptureApplication(process.MainWindowTitle);
break;
}
}
}
In the process.MainWindowTitle in the MainWindowTitles i see: GrADS 2.0.2.oga.2 This is fired from the external process Xming. Xming is a small server that connect to the internet and then show a console window and the GrADS 2.0.2.oga.2 is the title of the window but i can't find in any place this GrADS 2.0.2.oga.2 file exe file. I can see the Xming on tray icon but i tried in Task Manager can't find the GrADS 2.0.2.oga.2 exe file on my hard disk.
CaptureApplication(process.MainWindowTitle);
When CaptureApplication get the MainWindowTitle in this case GrADS 2.0.2.oga.2 it should capture the window and stick it add it to the pictureBox on form1. But it's not.
public void CaptureApplication(string _title)
{
string _wndcls = "ConsoleWindowClass";
STARTUPINFO si = new STARTUPINFO();
PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
CreateProcess(_title, null, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
IntPtr _wndConsole = IntPtr.Zero;
for (int i = 0; i < 30; i++)
{
_wndConsole = FindWindow(_wndcls, _title);
if (_wndConsole == IntPtr.Zero)
{
System.Threading.Thread.Sleep(10);
continue;
}
break;
}
IntPtr value = SetParent(_wndConsole, this.pictureBox1.Handle);
int style = GetWindowLong(_wndConsole, -16);
style &= -12582913;
SetWindowLong(_wndConsole, -16, style);
SendMessage(_wndConsole, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
Maybe GrADS 2.0.2.oga.2 is not exe file not a process ? I can't figure out how to capture it.
This window on the left i need to capture. Maybe the GrADS 2.0.2.oga.2 is not a self process ? It is showing on after the Xming is running.