{"action":"created","issue":{"url":"https://api.github.com/repos/cbucher/console/issues/212","labels_url":"https://api.github.com/repos/cbucher/console/issues/212/labels{/name}","comments_url":"https://api.github.com/repos/cbucher/console/issues/212/comments","events_url":"https://api.github.com/repos/cbucher/console/issues/212/events","html_url":"https://github.com/cbucher/console/issues/212","id":78240884,"number":212,"title":"[feature request] Aggregate taskbar state/progress","user":{"login":"alejandro5042","id":3143819,"avatar_url":"https://avatars.githubusercontent.com/u/3143819?v=3","gravatar_id":"","url":"https://api.github.com/users/alejandro5042","html_url":"https://github.com/alejandro5042","followers_url":"https://api.github.com/users/alejandro5042/followers","following_url":"https://api.github.com/users/alejandro5042/following{/other_user}","gists_url":"https://api.github.com/users/alejandro5042/gists{/gist_id}","starred_url":"https://api.github.com/users/alejandro5042/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alejandro5042/subscriptions","organizations_url":"https://api.github.com/users/alejandro5042/orgs","repos_url":"https://api.github.com/users/alejandro5042/repos","events_url":"https://api.github.com/users/alejandro5042/events{/privacy}","received_events_url":"https://api.github.com/users/alejandro5042/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cbucher/console/labels/rejected%20feature","name":"rejected feature","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-19T20:32:41Z","updated_at":"2015-05-22T17:40:58Z","closed_at":null,"body":"I have a few scripts that set the progress bar state of the PowerShell window. That way you can have a long running operation in the background and monitor it's progress on the taskbar. ConsoleZ should aggregate the task bar states of each of its tabs and modify its own taskbar state to this aggregate value.\r\n\r\nInformation on the Windows 7 taskbar API:\r\nhttps://msdn.microsoft.com/en-us/magazine/dd942846.aspx\r\n\r\nHere is a PowerShell script that displays the capability of the Windows taskbar in a console window. You just have to run this from a regular PowerShell window. Save this snipplet to a Test.ps1 file and run it. You'll need to update the path to where your WindowsAPICodePack.Shell.dll exists.\r\n\r\n```\r\nparam\r\n(\r\n    $PathToWindowsAPICodePack = \"**PATH**\\WindowsAPICodePack1.1\\Microsoft.WindowsAPICodePack.Shell.dll\"\r\n)\r\n\r\nAdd-Type -TypeDefinition @\"\r\n// http://learn-powershell.net/2013/08/26/make-a-window-flash-in-taskbar-using-powershell-and-pinvoke/\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Runtime.InteropServices;\r\n\r\npublic class NativeMethods\r\n{\r\n    [StructLayout(LayoutKind.Sequential)]\r\n    public struct FLASHWINFO\r\n    {\r\n        public UInt32 cbSize;\r\n        public IntPtr hwnd;\r\n        public UInt32 dwFlags;\r\n        public UInt32 uCount;\r\n        public UInt32 dwTimeout;\r\n    }\r\n\r\n    // Stop flashing. The system restores the window to its original state. \r\n    const UInt32 FLASHW_STOP = 0;\r\n    \r\n    // Flash the window caption. \r\n    const UInt32 FLASHW_CAPTION = 1;\r\n    \r\n    // Flash the taskbar button. \r\n    const UInt32 FLASHW_TRAY = 2;\r\n    \r\n    // Flash both the window caption and taskbar button.\r\n    // This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags. \r\n    const UInt32 FLASHW_ALL = 3;\r\n    \r\n    // Flash continuously, until the FLASHW_STOP flag is set. \r\n    const UInt32 FLASHW_TIMER = 4;\r\n    \r\n    // Flash continuously until the window comes to the foreground. \r\n    const UInt32 FLASHW_TIMERNOFG = 12; \r\n\r\n    [DllImport(\"user32.dll\")]\r\n    [return: MarshalAs(UnmanagedType.Bool)]\r\n    static extern bool FlashWindowEx(ref FLASHWINFO pwfi);\r\n\r\n    public static bool FlashWindow(IntPtr handle, UInt32 timeout, UInt32 count)\r\n    {\r\n        IntPtr hWnd = handle;\r\n        FLASHWINFO fInfo = new FLASHWINFO();\r\n\r\n        fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));\r\n        fInfo.hwnd = hWnd;\r\n        fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;\r\n        fInfo.uCount = count;\r\n        fInfo.dwTimeout = timeout;\r\n\r\n        return FlashWindowEx(ref fInfo);\r\n    }\r\n}\r\n\"@\r\n\r\ntry\r\n{\r\n    [void][Reflection.Assembly]::LoadFrom($PathToWindowsAPICodePack)\r\n    $TaskBarObject = [Microsoft.WindowsAPICodePack.TaskBar.TaskBarManager]::Instance\r\n    \r\n    if ([Microsoft.WindowsAPICodePack.TaskBar.TaskBarManager]::IsPlatformSupported)\r\n    {\r\n        $TaskBarObject.SetProgressState(\"Indeterminate\")\r\n        sleep 2\r\n        \r\n        $TaskBarObject.SetProgressState(\"Normal\")\r\n\r\n        for ($i = 0; $i -lt 100; $i++)\r\n        {\r\n            $TaskBarObject.SetProgressValue($i, 100)\r\n            sleep -milliseconds 10\r\n            \r\n            if ($i -eq 40)\r\n            {\r\n                $TaskBarObject.SetProgressState(\"Paused\")\r\n                sleep 1\r\n                $TaskBarObject.SetProgressState(\"Normal\")\r\n            }\r\n            \r\n            if ($i -eq 60)\r\n            {\r\n                $TaskBarObject.SetProgressState(\"Error\")\r\n            }\r\n        }\r\n        \r\n        [void][NativeMethods]::FlashWindow((Get-Process -Id $pid).MainWindowHandle, 150, 10)\r\n    }\r\n}\r\ncatch\r\n{\r\n    Write-Error $_\r\n}\r\nfinally\r\n{\r\n    try\r\n    {\r\n        $TaskBarObject.SetProgressState(\"NoProgress\")\r\n    }\r\n    catch\r\n    {\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/cbucher/console/issues/comments/104723924","html_url":"https://github.com/cbucher/console/issues/212#issuecomment-104723924","issue_url":"https://api.github.com/repos/cbucher/console/issues/212","id":104723924,"user":{"login":"alejandro5042","id":3143819,"avatar_url":"https://avatars.githubusercontent.com/u/3143819?v=3","gravatar_id":"","url":"https://api.github.com/users/alejandro5042","html_url":"https://github.com/alejandro5042","followers_url":"https://api.github.com/users/alejandro5042/followers","following_url":"https://api.github.com/users/alejandro5042/following{/other_user}","gists_url":"https://api.github.com/users/alejandro5042/gists{/gist_id}","starred_url":"https://api.github.com/users/alejandro5042/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alejandro5042/subscriptions","organizations_url":"https://api.github.com/users/alejandro5042/orgs","repos_url":"https://api.github.com/users/alejandro5042/repos","events_url":"https://api.github.com/users/alejandro5042/events{/privacy}","received_events_url":"https://api.github.com/users/alejandro5042/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T17:40:58Z","updated_at":"2015-05-22T17:40:58Z","body":"A real bummer. I appreciate your quick turnaround!\r\n\r\nI realize this is a low priority request and I understand if we don't do it. But it would be really cool. I wonder if there is any other way to communicate progress to the ConsoleZ process. A custom named pipe to communicate extra details? How about calling an .exe that does IPC? I'd love to help by writing any PowerShell scripts to expose this functionality to users.\r\n\r\nMy build scripts already have progress bars, but this would be ideal since users won't need to monitor the console. It would benefit the ~300 engineers who my scripts everyday!"}}