/// <summary> /// Create LgProcess form a windows process /// </summary> /// <param name="process"></param> /// <returns></returns> public static LgProcess FromProcess(Process process) { LgProcess p = new LgProcess(process.ProcessName, process.MainModule.FileName, process.ProcessName, process.StartInfo.Arguments); p.WinProcess = process; return(p); }
public static Boolean Stop(LgProcess process) { Process p = process.WinProcess; p.Refresh(); try { if (!p.HasExited) p.Kill(); } catch (Exception e) { MessageBox.Show(e.Message); } return p.HasExited; }
/// <summary> /// Starts process and sets the handler to the object /// </summary> /// <param name="process"></param> /// <returns></returns> public static Boolean Start(LgProcess process) { try { Process p = Process.Start(process.FullPath, process.Arguments); // wait a little in order for the handler to be assigned p.WaitForInputIdle(); process.WinProcess = p; } catch (Exception e) { MessageBox.Show(e.Message); } return process.WinProcess != null && process.WinProcess.Responding; }
/// <summary> /// Add new Window to the config from a coordinate in the screen. Usually from a mouse click. /// </summary> /// <param name="point">point in screen</param> /// <returns></returns> internal Boolean AddWindow(LgPoint point) { Boolean result = true; Process p = LgProcessManager.GetProcessAtCoordiante(point); // before adding check if it is current process if (!LgProcessManager.IsCurrentProcess(p)) { LgProcess process = LgProcess.FromProcess(p); LgRectangle rec = LgProcessManager.GetWindowRectange(process); LgWindow window = new LgWindow(rec.GetTopLeft(), rec.GetSize(), process); // add to list Windows.Add(window); Console.WriteLine(window); } else { result = false; } return(result); }
/// <summary> /// Create LgProcess form a windows process /// </summary> /// <param name="process"></param> /// <returns></returns> public static LgProcess FromProcess(Process process) { LgProcess p = new LgProcess(process.ProcessName, process.MainModule.FileName, process.ProcessName, process.StartInfo.Arguments); p.WinProcess = process; return p; }
public LgWindow(LgPoint top, LgSize size, LgProcess process) { TopLeft = top; Size = size; Process = process; }
public LgWindow(LgPoint top, LgPoint bottom, LgProcess process) { TopLeft = top; Process = process; }
/// <summary> /// Checks if the process name matches any running processes /// </summary> /// <param name="process"></param> /// <returns></returns> public static Boolean isRunning(LgProcess process) { return Process.GetProcessesByName(process.Name).Length > 0; }
/// <summary> /// Minimize window /// </summary> /// <param name="process"></param> public static void MinimizeWindow(LgProcess process) { ShowWindowAsync(process.WinProcess.MainWindowHandle, 6); }
/// <summary> /// Show window /// </summary> /// <param name="process"></param> public static void ShowWindow(LgProcess process) { ShowWindowAsync(process.WinProcess.MainWindowHandle, 1); }
/// <summary> /// Return the size of the window /// </summary> /// <param name="process"></param> /// <returns></returns> public static LgRectangle GetWindowRectange(LgProcess process) { RECT lpRect = default(RECT); GetWindowRect(new HandleRef(process, process.WinProcess.MainWindowHandle), out lpRect); return new LgRectangle(lpRect.Left, lpRect.Top, lpRect.Right, lpRect.Bottom); }