Exemplo n.º 1
0
 private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0 &&
         MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
     {
         MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         LgPoint point = new LgPoint(hookStruct.pt.x, hookStruct.pt.y);
         Config?.AddWindow(point);
         Console.WriteLine(hookStruct.pt.x + ", " + hookStruct.pt.y);
     }
     return CallNextHookEx(_hookID, nCode, wParam, lParam);
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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; 
 }
Exemplo n.º 4
0
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size    = size;
     Process = process;
 }
Exemplo n.º 5
0
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Get process under mouse cursor
        /// </summary>
        /// <returns></returns>
        public static Process GetProcessAtCoordiante(LgPoint point)
        {
            uint pid = 0;
            POINT ptCursor = new POINT(point.X, point.Y);
            
            IntPtr handle = WindowFromPoint(ptCursor);
            GetWindowThreadProcessId(handle, out pid);

            return Process.GetProcessById((int)pid);
        }
Exemplo n.º 7
0
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size = size;
     Process = process;
 }
Exemplo n.º 8
0
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }