Example #1
0
        protected virtual void OnMoveSizeStart(object sender, WinEventProcEventArgs e)
        {
            MouseInput.GetMousePoint();

            WindowDraggingHWND = e._hwnd;
            IsStartDragging    = true;
            WindowHelper.GetWindowRect(e._hwnd, ref currentWindowRECT);
            lastWindowRECT = currentWindowRECT;

            string name = WindowHelper.GetTitleOfWindow(e._hwnd);

            CurrentLog.Add(LogEntryType.WindowsEvent, "Window MoveSize Started: " + name + " (" + e._hwnd.ToString() + ") at " + MouseInput.mousePoint.ToString());
        }
Example #2
0
        protected virtual void OnObjectCreated(object sender, WinEventProcEventArgs e)
        {
            if (WindowHelper.IsWindow(e._hwnd))
            {
                string title = WindowHelper.GetTitleOfWindow(e._hwnd);
                OnWindowCreated(sender, new OpenCloseEventArgs()
                {
                    HWND = e._hwnd, Title = title
                });
                return;
            }

            CurrentLog.Add(LogEntryType.WindowsEvent, "Object Created: (" + e._hwnd.ToString() + ")");
        }
Example #3
0
        protected virtual void OnForegroundChanged(object sender, WinEventProcEventArgs e)
        {
            MouseInput.GetMousePoint();

            lastForegroundHWND    = currentForegroundHWND;
            currentForegroundHWND = e._hwnd;

            lastForegroundName    = currentForegroundName;
            currentForegroundName = WindowHelper.GetTitleOfWindow(e._hwnd);

            if (lastForegroundHWND != currentForegroundHWND)
            {
                CurrentLog.Add(LogEntryType.WindowsEvent, "Foreground Window Changed: from " + lastForegroundName + " (" + lastForegroundHWND.ToString() + ") to " + currentForegroundName + " (" + currentForegroundHWND.ToString() + ") at " + MouseInput.mousePoint.ToString());
            }
        }
Example #4
0
        protected virtual void OnObjectDestroyed(object sender, WinEventProcEventArgs e)
        {
            AWindow awin = WindowHelper.windowList.FirstOrDefault(awindow => awindow.Hwnd == e._hwnd);

            if (awin != null)
            {
                OnWindowDestroyed(sender, new OpenCloseEventArgs()
                {
                    HWND = e._hwnd, Title = awin.Title
                });
                return;
            }

            CurrentLog.Add(LogEntryType.WindowsEvent, "Object Destroyed: (" + e._hwnd.ToString() + ")");
        }
Example #5
0
        protected virtual void OnStateChanged(object sender, WinEventProcEventArgs e)
        {
            AWindow awin = WindowHelper.windowList.FirstOrDefault(awindow => awindow.Hwnd == e._hwnd);

            if (awin != null)
            {
                WINDOWPLACEMENT newPlacement = new WINDOWPLACEMENT(true);
                WindowHelper.GetWindowPlacement(e._hwnd, ref newPlacement);
                awin.LastPlacement = awin.Placement;
                awin.Placement     = newPlacement;

                OnWindowStateChanged(sender, new WindowStateChangedEventArgs()
                {
                    HWND = e._hwnd, oldPlacement = awin.LastPlacement, newPlacement = awin.Placement
                });
            }
        }
Example #6
0
        protected virtual void OnObjectNameChanged(object sender, WinEventProcEventArgs e)
        {
            string  newName = WindowHelper.GetTitleOfWindow(e._hwnd);
            AWindow awin    = WindowHelper.windowList.FirstOrDefault(awindow => awindow.Hwnd == e._hwnd);

            if (awin != null)
            {
                string oldName = awin.Title;
                OnWindowNameChanged(sender, new NameChangeEventArgs()
                {
                    HWND = e._hwnd, oldName = oldName, newName = newName
                });
                return;
            }

            CurrentLog.Add(LogEntryType.WindowsEvent, "Object Name Changed: " + newName + "(" + e._hwnd.ToString() + ")");
        }
Example #7
0
        protected virtual void OnMoveSizeEnd(object sender, WinEventProcEventArgs e)
        {
            MouseInput.GetMousePoint();

            WindowHelper.GetWindowRect(e._hwnd, ref currentWindowRECT);

            if (IsWindowMoving)
            {
                OnWindowMoveEnd(sender, new MouseWindowEventArgs()
                {
                    HWND = e._hwnd, MousePoint = MouseInput.mousePoint
                });
                IsWindowMoving = false;
            }

            if (IsWindowSizing)
            {
                OnWindowSizeEnd(sender, new MouseWindowEventArgs()
                {
                    HWND = e._hwnd, MousePoint = MouseInput.mousePoint
                });
                IsWindowSizing = false;
            }

            if (IsDragMoveOver)
            {
                OnMouseWindowDragMoveDrop(sender, new MouseWindowDragEventArgs()
                {
                    DraggingHWND = e._hwnd, ToHWND = WindowDragOverHWND, MousePoint = MouseInput.mousePoint
                });
                IsDragMoveOver = false;
            }

            if (IsDragSizeOver)
            {
                OnMouseWindowDragSizeDrop(sender, new MouseWindowDragEventArgs()
                {
                    DraggingHWND = e._hwnd, ToHWND = WindowDragOverHWND, MousePoint = MouseInput.mousePoint
                });
                IsDragSizeOver = false;
            }
        }
Example #8
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     foreach (WinEventHook hook in RegisteredHooks)
     {
         if (hook.IsHooked() && (eventType >= hook.EventMin && eventType <= hook.EventMax))
         {
             WinEventProcEventArgs args = new WinEventProcEventArgs()
             {
                 _hWinEventHook = hWinEventHook,
                 _eventType     = eventType,
                 _hwnd          = hwnd,
                 _idObject      = idObject,
                 _idChild       = idChild,
                 _dwEventThread = dwEventThread,
                 _dwmsEventTime = dwmsEventTime,
             };
             hook.eventHandler.Invoke(hWinEventHook, args);
         }
     }
 }
Example #9
0
        protected virtual void OnLocationChanged(object sender, WinEventProcEventArgs e)
        {
            MouseInput.GetMousePoint();

            WindowHelper.GetWindowRect(e._hwnd, ref currentWindowRECT);

            if (IsStartDragging && e._hwnd == WindowDraggingHWND)
            {
                if (currentWindowRECT.Equals(lastWindowRECT) == false)
                {
                    int currentWidth  = currentWindowRECT.Right - currentWindowRECT.Left;
                    int currentHeight = currentWindowRECT.Bottom - currentWindowRECT.Top;
                    int lastWidth     = lastWindowRECT.Right - lastWindowRECT.Left;
                    int lastHeight    = lastWindowRECT.Bottom - lastWindowRECT.Top;

                    if (currentWidth == lastWidth && currentHeight == lastHeight)
                    {
                        OnWindowMoveStart(sender, new MouseWindowEventArgs()
                        {
                            HWND = e._hwnd, MousePoint = MouseInput.mousePoint
                        });
                        WindowDraggingHWND = e._hwnd;
                        IsWindowMoving     = true;
                        IsStartDragging    = false;
                    }
                    else
                    {
                        OnWindowSizeStart(sender, new MouseWindowEventArgs()
                        {
                            HWND = e._hwnd, MousePoint = MouseInput.mousePoint
                        });
                        WindowDraggingHWND = e._hwnd;
                        IsWindowSizing     = true;
                        IsStartDragging    = false;
                    }
                }
            }
        }
Example #10
0
 protected virtual void OnMinimizeEnd(object sender, WinEventProcEventArgs e)
 {
     OnStateChanged(sender, e);
 }