protected void HookEvent(uint eventType)
        {
            procDelegate = new WinAPI.WinEventDelegate(WinEventProc);

            // Listen for foreground changes across all processes/threads on current desktop...
            m_hook = WinAPI.SetWinEventHook(eventType, eventType, IntPtr.Zero,
                                            procDelegate, 0, 0, 0);
        }
        protected void HookEvent(uint eventType)
        {
            procDelegate = new WinAPI.WinEventDelegate(WinEventProc);

            // Listen for foreground changes across all processes/threads on current desktop...
            m_hook = WinAPI.SetWinEventHook(eventType, eventType, IntPtr.Zero,
                    procDelegate, 0, 0, 0);
        }
示例#3
0
        public VirtualDesktopGridManager(SysTrayProcess sysTrayProcess, SettingValues settings)
        {
            this.settings       = settings;
            this.sysTrayProcess = sysTrayProcess;

            foregroundWindowChangedDelegate = new WinAPI.WinEventDelegate(ForegroundWindowChanged);
            fgWindowHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, foregroundWindowChangedDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);

            Start();
        }
示例#4
0
 public WinEvent()
 {
     winEventProc = WinEventCallback;
     hookID       = WinAPI.SetWinEventHook(
         WinAPI.WinEvent.SystemForeground,
         WinAPI.WinEvent.SystemForeground,
         IntPtr.Zero, winEventProc,
         0,
         0,
         WinAPI.WinEventFlag.OutOfContext);
 }
 public static void HookWidgetTopMost()
 {
     try
     {
         _delegate       = BringWidgetsIntoFocus;
         _mainHandleHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, _delegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
     }
     catch (Exception e)
     {
     }
     SetWindowTimer          = new Timer(1000);
     SetWindowTimer.Elapsed += SetWindowTimerOnElapsed;
     SetWindowTimer.Start();
 }
 public static void HookWidgetTopMost()
 {
     try
     {
         _delegate = BringWidgetsIntoFocus;
         _mainHandleHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, _delegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
     }
     catch (Exception e)
     {
     }
     SetWindowTimer = new Timer(1000);
     SetWindowTimer.Elapsed += SetWindowTimerOnElapsed;
     SetWindowTimer.Start();
 }
 public static void HookWidgetTopMost()
 {
     try
     {
         _delegate = BringWidgetsIntoFocus;
         _mainHandleHook = WinAPI.SetWinEventHook(WinAPI.EventSystemForeground, WinAPI.EventSystemForeground, IntPtr.Zero, _delegate, 0, 0, WinAPI.WineventOutofcontext);
     }
     catch (Exception ex)
     {
         LogHelper.Log(Logger, ex, LogLevel.Error);
     }
     SetWindowTimer = new Timer(1000);
     SetWindowTimer.Elapsed += SetWindowTimerOnElapsed;
     SetWindowTimer.Start();
 }
 public static void HookWidgetTopMost()
 {
     try
     {
         _delegate       = BringWidgetsIntoFocus;
         _mainHandleHook = WinAPI.SetWinEventHook(WinAPI.EventSystemForeground, WinAPI.EventSystemForeground, IntPtr.Zero, _delegate, 0, 0, WinAPI.WineventOutofcontext);
     }
     catch (Exception ex)
     {
         LogHelper.Log(Logger, ex, LogLevel.Error);
     }
     SetWindowTimer          = new Timer(1000);
     SetWindowTimer.Elapsed += SetWindowTimerOnElapsed;
     SetWindowTimer.Start();
 }
        public VirtualDesktopGridManager(SysTrayProcess sysTrayProcess, SettingValues settings)
        {
            this.settings       = settings;
            this.sysTrayProcess = sysTrayProcess;

            VDMHelper = VdmHelperFactory.CreateInstance();
            VDMHelper.Init();

            foregroundWindowChangedDelegate = new WinAPI.WinEventDelegate(ForegroundWindowChanged);
            fgWindowHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, foregroundWindowChangedDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);

            // Create a custom message ID for other processes to trigger actions.
            commandWindowMessage = RegisterWindowMessage("VIRTUALDESKTOPGRIDSWITCHER_COMMAND");
            Application.AddMessageFilter(this);

            Start();
        }
示例#10
0
        private void InitializeContext()
        {
            //Create notify icon, with it's context menu:
            components = new Container();
            notifyIcon = new NotifyIcon(components)
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Visible          = true
            };
            UpdateNotifyIcon();
            ToolStripMenuItem item = new ToolStripMenuItem("&Exit");

            item.Click += ExitItem_Click;
            notifyIcon.ContextMenuStrip.Items.Add(item);

            //Create WindowsEvent hook:
            winEventDelegate = new WinAPI.WinEventDelegate(WinEventCallback);
            GCSafetyHandle   = GCHandle.Alloc(winEventDelegate);
            winEventHook     = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_MOVESIZESTART, WinAPI.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, winEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT | WinAPI.WINEVENT_SKIPOWNPROCESS);

            SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);

            moveDetect = new MoveDetect(BeginMovingWindow, EndMovingWindow, ContinueMovingWindow);
        }
示例#11
0
        public SanebarWindow(bool primary = true)
        {
            // Primary Sanebar window handles other Sanebar windows
            if (primary)
            {
                isPrimary            = true;
                primarySanebarWindow = this;

                WinAPI.DWMCOLORIZATIONPARAMS dwmColors = new WinAPI.DWMCOLORIZATIONPARAMS();
                WinAPI.DwmGetColorizationParameters(ref dwmColors);
                System.Drawing.Color clr = System.Drawing.Color.FromArgb((int)dwmColors.ColorizationColor);
                Color clrAero            = Color.FromArgb(clr.A, clr.R, clr.G, clr.B);
                //Color clrAero = Color.FromArgb(255, clr.R, clr.G, clr.B);
                activeBackground  = new SolidColorBrush(clrAero);
                defaultBackground = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0));

                quickLaunch = new QuickLaunch();


                // Create a Sanebar window for each monitor
                sanebarWindows    = new SanebarWindow[System.Windows.Forms.Screen.AllScreens.Length];
                sanebarWindows[0] = this;
                int i = 1;

                foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                {
                    if (screen.Primary == true)
                    {
                        this.Top   = screen.WorkingArea.Top;
                        this.Left  = screen.WorkingArea.Left;
                        this.Width = screen.WorkingArea.Right - screen.WorkingArea.Left;
                        screenThis = screen;
                    }
                    else
                    {
                        sanebarWindows[i]            = new SanebarWindow(false);
                        sanebarWindows[i].Top        = screen.WorkingArea.Top;
                        sanebarWindows[i].Left       = screen.WorkingArea.Left;
                        sanebarWindows[i].Width      = screen.WorkingArea.Right - screen.WorkingArea.Left;
                        sanebarWindows[i].screenThis = screen;
                        sanebarWindows[i].Show();
                        i++;
                    }
                }


                winEventDelegate = new WinAPI.WinEventDelegate(WinEventProc);

                // EVENT_SYSTEM_FOREGROUND
                IntPtr m_hhook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, winEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT | WinAPI.WINEVENT_SKIPOWNPROCESS);
                hooks.Add(m_hhook);

                // EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_NAMECHANGE
                m_hhook = WinAPI.SetWinEventHook(WinAPI.EVENT_OBJECT_LOCATIONCHANGE, WinAPI.EVENT_OBJECT_NAMECHANGE, IntPtr.Zero, winEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT | WinAPI.WINEVENT_SKIPOWNPROCESS);
                hooks.Add(m_hhook);

                // EVENT_SYSTEM_MINIMIZEEND
                m_hhook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_MINIMIZEEND, WinAPI.EVENT_SYSTEM_MINIMIZEEND, IntPtr.Zero, winEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT | WinAPI.WINEVENT_SKIPOWNPROCESS);
                hooks.Add(m_hhook);
            }

            exceptionList = Properties.Settings.Default.ExceptionList;
            if (exceptionList == null)
            {
                exceptionList = new System.Collections.Specialized.StringCollection();
            }

            InitializeComponent();

            this.Title  = App.APP_TITLE;
            this.Height = System.Windows.Forms.SystemInformation.CaptionHeight;
        }
 public ApplicationPanel()
 {
     // setup up the hook to watch for all EVENT_SYSTEM_FOREGROUND events system wide
     this._WinEventDelegate = new WinAPI.WinEventDelegate(WinEventProc);
     m_hWinEventHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, this._WinEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
 }
示例#13
0
 public ApplicationPanel()
 {
     // setup up the hook to watch for all EVENT_SYSTEM_FOREGROUND events system wide
     this._WinEventDelegate = new WinAPI.WinEventDelegate(WinEventProc);
     m_hWinEventHook        = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, this._WinEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
 }