public void Initialize()
        {
            try
            {
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                SetTaskmanWindow(_HookWin.Handle);
                //'Register to receive shell-related events
                //SetTaskmanWindow(hookWin.Handle)
                RegisterShellHookWindow(_HookWin.Handle);

                //'Assume no error occurred
                WM_SHELLHOOKMESSAGE       = RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                SetMinimizedMetrics();


                int msg = RegisterWindowMessage("TaskbarCreated");
                SendMessage(new IntPtr(0xffff), msg, IntPtr.Zero, IntPtr.Zero);
                SendMessage(GetDesktopWindow(), 0x0400, IntPtr.Zero, IntPtr.Zero);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
Example #2
0
        private void initialize()
        {
            IsStarting = true;

            try
            {
                CairoLogger.Instance.Debug("Starting WindowsTasksService");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE         = RegisterWindowMessage("SHELLHOOK");
                WM_TASKBARCREATEDMESSAGE    = RegisterWindowMessage("TaskbarCreated");
                TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated");
                _HookWin.MessageReceived   += ShellWinProc;

                // set window for ITaskbarList
                setTaskbarListHwnd();

                // adjust minimize animation
                SetMinimizedMetrics();

                // prepare collections
                groupedWindows = CollectionViewSource.GetDefaultView(Windows);
                groupedWindows.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
                groupedWindows.CollectionChanged += groupedWindows_Changed;
                groupedWindows.Filter             = groupedWindows_Filter;
                var taskbarItemsView = groupedWindows as ICollectionViewLiveShaping;
                taskbarItemsView.IsLiveFiltering = true;
                taskbarItemsView.LiveFilteringProperties.Add("ShowInTaskbar");
                taskbarItemsView.IsLiveGrouping = true;
                taskbarItemsView.LiveGroupingProperties.Add("Category");

                // enumerate windows already opened
                EnumWindows(new CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);
                    if (win.ShowInTaskbar && !Windows.Contains(win))
                    {
                        Windows.Add(win);
                    }
                    return(true);
                }), 0);

                // register for app grabber changes so that our app association is accurate
                AppGrabber.AppGrabber.Instance.CategoryList.CategoryChanged += CategoryList_CategoryChanged;
            }
            catch (Exception ex)
            {
                CairoLogger.Instance.Info("Unable to start WindowsTasksService: " + ex.Message);
            }

            IsStarting = false;
        }
Example #3
0
        internal void Initialize()
        {
            if (IsInitialized)
            {
                return;
            }

            try
            {
                CairoLogger.Instance.Debug("Starting WindowsTasksService");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE         = RegisterWindowMessage("SHELLHOOK");
                WM_TASKBARCREATEDMESSAGE    = RegisterWindowMessage("TaskbarCreated");
                TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated");
                _HookWin.MessageReceived   += ShellWinProc;

                if (Shell.IsWindows8OrBetter)
                {
                    // set event hook for uncloak events
                    uncloakEventProc = UncloakEventCallback;

                    if (uncloakEventHook == IntPtr.Zero)
                    {
                        uncloakEventHook = SetWinEventHook(
                            EVENT_OBJECT_UNCLOAKED,
                            EVENT_OBJECT_UNCLOAKED,
                            IntPtr.Zero,
                            uncloakEventProc,
                            0,
                            0,
                            WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
                    }
                }

                // set window for ITaskbarList
                setTaskbarListHwnd();

                // adjust minimize animation
                SetMinimizedMetrics();

                // enumerate windows already opened and set active window
                getInitialWindows();

                IsInitialized = true;
            }
            catch (Exception ex)
            {
                CairoLogger.Instance.Info("Unable to start WindowsTasksService: " + ex.Message);
            }
        }
        private void initialize()
        {
            IsStarting = true;

            try
            {
                CairoLogger.Instance.Debug("Starting WindowsTasksService");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE       = RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                // adjust minimize animation
                SetMinimizedMetrics();

                // prepare collections
                groupedWindows = CollectionViewSource.GetDefaultView(Windows);
                groupedWindows.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
                groupedWindows.CollectionChanged += groupedWindows_Changed;
                groupedWindows.Filter             = groupedWindows_Filter;
                var taskbarItemsView = groupedWindows as ICollectionViewLiveShaping;
                taskbarItemsView.IsLiveFiltering = true;
                taskbarItemsView.LiveFilteringProperties.Add("ShowInTaskbar");

                // enumerate windows already opened
                EnumWindows(new CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);
                    if (win.ShowInTaskbar && !Windows.Contains(win))
                    {
                        this.Windows.Add(win);
                    }
                    return(true);
                }), 0);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            IsStarting = false;
        }
Example #5
0
        private void initialize()
        {
            IsStarting = true;

            try
            {
                Trace.WriteLine("Starting WindowsTasksService");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE       = RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                // adjust minimize animation
                SetMinimizedMetrics();

                // enumerate windows already opened
                EnumWindows(new CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);
                    if (win.ShowInTaskbar && !Windows.Contains(win))
                    {
                        this.Windows.Add(win);
                    }
                    return(true);
                }), 0);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            IsStarting = false;
        }
        public void Initialize()
        {
            try
            {
                Trace.WriteLine("Starting WindowsTasksService");
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                NativeMethods.SetTaskmanWindow(_HookWin.Handle);
                //'Register to receive shell-related events
                NativeMethods.RegisterShellHookWindow(_HookWin.Handle);

                //'Assume no error occurred
                WM_SHELLHOOKMESSAGE       = NativeMethods.RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                SetMinimizedMetrics();


                //int msg = NativeMethods.RegisterWindowMessage("TaskbarCreated");
                IntPtr ptr = new IntPtr(0xffff);
                //IntPtr hDeskWnd = NativeMethods.GetDesktopWindow();
                //NativeMethods.SendMessageTimeout(ptr, (uint)msg, IntPtr.Zero, IntPtr.Zero, 2, 200, ref ptr);
                //NativeMethods.SendMessageTimeout(hDeskWnd, 0x0400, IntPtr.Zero, IntPtr.Zero, 2, 200, ref hDeskWnd);

                NativeMethods.EnumWindows(new NativeMethods.CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);
                    if (win.ShowInTaskbar && !Windows.Contains(win))
                    {
                        this.Windows.Add(win);
                    }
                    return(true);
                }), 0);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
Example #7
0
        private void initialize()
        {
            try
            {
                CairoLogger.Instance.Debug("Starting WindowsTasksService");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE         = RegisterWindowMessage("SHELLHOOK");
                WM_TASKBARCREATEDMESSAGE    = RegisterWindowMessage("TaskbarCreated");
                TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated");
                _HookWin.MessageReceived   += ShellWinProc;

                if (Interop.Shell.IsWindows8OrBetter)
                {
                    // set event hook for uncloak events
                    uncloakEventProc = UncloakEventCallback;

                    if (uncloakEventHook == IntPtr.Zero)
                    {
                        uncloakEventHook = SetWinEventHook(
                            EVENT_OBJECT_UNCLOAKED,
                            EVENT_OBJECT_UNCLOAKED,
                            IntPtr.Zero,
                            uncloakEventProc,
                            0,
                            0,
                            WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
                    }
                }

                // set window for ITaskbarList
                setTaskbarListHwnd();

                // adjust minimize animation
                SetMinimizedMetrics();

                // prepare collections
                groupedWindows = CollectionViewSource.GetDefaultView(Windows);
                groupedWindows.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
                groupedWindows.CollectionChanged += groupedWindows_Changed;
                groupedWindows.Filter             = groupedWindows_Filter;

                if (groupedWindows is ICollectionViewLiveShaping taskbarItemsView)
                {
                    taskbarItemsView.IsLiveFiltering = true;
                    taskbarItemsView.LiveFilteringProperties.Add("ShowInTaskbar");
                    taskbarItemsView.IsLiveGrouping = true;
                    taskbarItemsView.LiveGroupingProperties.Add("Category");
                }

                // enumerate windows already opened
                EnumWindows(new CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);

                    if (win.CanAddToTaskbar && win.ShowInTaskbar && !Windows.Contains(win))
                    {
                        Windows.Add(win);
                    }

                    return(true);
                }), 0);

                // register for app grabber changes so that our app association is accurate
                AppGrabber.AppGrabber.Instance.CategoryList.CategoryChanged += CategoryList_CategoryChanged;
            }
            catch (Exception ex)
            {
                CairoLogger.Instance.Info("Unable to start WindowsTasksService: " + ex.Message);
            }
        }
Example #8
0
        public void Initialize()
        {
            try
            {
                Trace.WriteLine("Starting WindowsTasksService");
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                SetTaskmanWindow(_HookWin.Handle);
                //'Register to receive shell-related events
                RegisterShellHookWindow(_HookWin.Handle);

                //'Assume no error occurred
                WM_SHELLHOOKMESSAGE = RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                SetMinimizedMetrics();

                int msg = RegisterWindowMessage("TaskbarCreated");
                IntPtr ptr = new IntPtr(0xffff);
                IntPtr hDeskWnd = GetDesktopWindow();
                Shell.SendMessageTimeout(ptr, (uint)msg, IntPtr.Zero, IntPtr.Zero, 2, 200, ref ptr);
                Shell.SendMessageTimeout(hDeskWnd, 0x0400, IntPtr.Zero, IntPtr.Zero, 2, 200, ref hDeskWnd);

                EnumWindows(new CallBackPtr((hwnd, lParam) =>
                {
                    ApplicationWindow win = new ApplicationWindow(hwnd, this);
                    if(win.ShowInTaskbar)
                        this.Windows.Add(win);
                    return true;
                }), 0);

            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
        public void Initialize()
        {
            try
            {
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                SetTaskmanWindow(_HookWin.Handle);
                //'Register to receive shell-related events
                //SetTaskmanWindow(hookWin.Handle)
                RegisterShellHookWindow(_HookWin.Handle);

                //'Assume no error occurred
                WM_SHELLHOOKMESSAGE = RegisterWindowMessage("SHELLHOOK");
                _HookWin.MessageReceived += ShellWinProc;

                SetMinimizedMetrics();

                int msg = RegisterWindowMessage("TaskbarCreated");
                SendMessage(new IntPtr(0xffff), msg, IntPtr.Zero, IntPtr.Zero);
                SendMessage(GetDesktopWindow(), 0x0400, IntPtr.Zero, IntPtr.Zero);

            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }