Example #1
0
        /// <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);
        }
Example #2
0
        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;
        }
Example #3
0
        /// <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;
        }
Example #4
0
        /// <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);
        }
Example #5
0
 /// <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;
 }
Example #6
0
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size    = size;
     Process = process;
 }
Example #7
0
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }
Example #8
0
 /// <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;
 }
Example #9
0
 /// <summary>
 /// Minimize window
 /// </summary>
 /// <param name="process"></param>
 public static void MinimizeWindow(LgProcess process)
 {
     ShowWindowAsync(process.WinProcess.MainWindowHandle, 6);
 }
Example #10
0
 /// <summary>
 /// Show window
 /// </summary>
 /// <param name="process"></param>
 public static void ShowWindow(LgProcess process)
 {
     ShowWindowAsync(process.WinProcess.MainWindowHandle, 1);
 }
Example #11
0
        /// <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);
        }
Example #12
0
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size = size;
     Process = process;
 }
Example #13
0
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }