コード例 #1
0
ファイル: IOManager.cs プロジェクト: aldialimucaj/lego
 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);
 }
コード例 #2
0
ファイル: LgConfig.cs プロジェクト: aldialimucaj/lego
        /// <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);
        }
コード例 #3
0
ファイル: LgConfig.cs プロジェクト: aldialimucaj/lego
 /// <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; 
 }
コード例 #4
0
ファイル: LgWindow.cs プロジェクト: aldialimucaj/lego
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size    = size;
     Process = process;
 }
コード例 #5
0
ファイル: LgWindow.cs プロジェクト: aldialimucaj/lego
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }
コード例 #6
0
ファイル: LgProcessManager.cs プロジェクト: aldialimucaj/lego
        /// <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);
        }
コード例 #7
0
ファイル: LgWindow.cs プロジェクト: aldialimucaj/lego
 public LgWindow(LgPoint top, LgSize size, LgProcess process)
 {
     TopLeft = top;
     Size = size;
     Process = process;
 }
コード例 #8
0
ファイル: LgWindow.cs プロジェクト: aldialimucaj/lego
 public LgWindow(LgPoint top, LgPoint bottom, LgProcess process)
 {
     TopLeft = top;
     Process = process;
 }