TOPIC about_MyMonitor SHORT DESCRIPTION Describes the basic concepts in using the MyMonitor module. LONG DESCRIPTION The MyMonitor module contains a small set of commands for monitoring active window use. The Get-WindowTime function uses another "helper" function called Get-ForegroundWindowProcess to retrieve the active window process. However, processes that don't have interactive windows or those associated with Task Switching are excluded. Get-WindowTime keeps track of how long you are spending on a window based primarily on its window title. At the end of the monitoring process, it writes results to the pipeline. Time : 00:00:18.9084682 Application : Thunderbird WindowTitle : Junk - Jeffery Hicks - Mozilla Thunderbird Product : Thunderbird Time : 00:00:12.6757123 Application : Windows PowerShell ISE WindowTitle : Administrator: Windows PowerShell ISE Product : Microsoft® Windows® Operating System Time : 00:00:49.1406603 Application : Microsoft Management Console WindowTitle : Hyper-V Manager Product : Microsoft® Windows® Operating System If the process does not have a WindowTitle property, then the function will first check for .MainModule.Description and if that doesn't exist, then the function will use the process name. The other information is pulled from the MainModule property so that you can evaluate how much time you are spending by application or product. MONITORING By default, Get-WindowTime will monitor active window use for 1 minute. You can specify a different number of minute or a specific date time. Another option is to use a process "trigger". This is the name of a process that you rarely use, such as CALC. When Get-WindowTime detects the presence of that process, it will stop monitoring and write results to the pipeline. Because monitoring will block the prompt, you also have an option to run everything in a background job. Note that if you terminate the background job you will not get any results. One potential drawback to this toolset, it that there is no way to pause and resume monitoring. Thus, you might have skewed results when you go to meetings or take a lunch break. One workaround is to select an application that you do not use, such as Calc.exe and run that during your away time. When you measure results, you can ignore or filter out that process. MEASURING When you are finished monitoring, you can use Measure-WindowTotal to analyze the data. Pipe your data to the command. The default is to display results by application. PS C:\> $data | Measure-WindowTotal Application TotalTime ----------- --------- Windows PowerShell ISE 00:00:12.6757123 Windows PowerShell 00:00:22.6393253 Google Chrome 00:01:54.1870428 Thunderbird 00:03:10.1524340 Microsoft Management Console 00:04:19.7252959 But you can also measure by product: PS C:\> $data | Measure-WindowTotal -Product Product TotalTime ------- --------- Google Chrome 00:01:54.1870428 Thunderbird 00:03:10.1524340 Microsoft® Windows® Operating System 00:04:55.0403335 or by Title. PS C:\> $data | Measure-WindowTotal -Title WindowTitle TotalTime ----------- --------- July 2014 - Mozilla Thunderbird 00:00:00.7309264 New Tab - Google Chrome 00:00:02.6440093 Calendar - Mozilla Thunderbird 00:00:02.7084472 Hootsuite - Google Chrome 00:00:07.6023926 Facebook - Google Chrome 00:00:09.0954287 Administrator: Windows PowerShell ISE 00:00:12.6757123 Junk - Jeffery Hicks - Mozilla Thunderbird 00:00:18.9084682 Administrator: Windows PowerShell 00:00:22.6393253 Inbox - Jeffery Hicks - Mozilla Thunderbird 00:00:29.1373713 Hyper-V Manager 00:00:49.1406603 Update Services 00:03:23.7454981 You can also filter by specifying a string or regular expression pattern for text in the Window title. This can be useful when you want to see how much time you are spending on a particular set of applications or products. PS C:\> $data | Measure-WindowTotal -Filter "facebook|hootsuite" Application TotalTime ----------- --------- Google Chrome 00:00:16.6978213 The last measure-related command is Get-WindowTimeSummary. To use this you will need a variable holding all of the work items. This will show you not only the total time for products or applications, but also a range of the first and last item for each. PS C:\> get-windowtimesummary $data | sort total | format-table -autosize Name Total Start End ---- ----- ----- --- Google Chrome Windows PowerShell ISE 00:00:00.2776561 8/25/2014 10:46:36 AM 8/25/2014 11:01:04 AM Microsoft Word 00:00:01.4462946 8/25/2014 12:14:50 PM 8/25/2014 12:18:34 PM Windows PowerShell 00:04:50.0923401 8/25/2014 11:38:14 AM 8/25/2014 12:19:31 PM Thunderbird 00:05:35.3980271 8/25/2014 12:02:32 PM 8/25/2014 12:19:04 PM Google Chrome 00:29:57.3321071 8/25/2014 11:56:36 AM 8/25/2014 12:20:27 PM CUSTOM VIEWS The MyMonitor module includes custom type and format extensions. The default display is a list. The module includes several views for Format-Table, but you should sort your data first, as the views group data by either product PS C:\> $data | sort Product | format-table -View Product or application PS C:\> $data | sort Application,Time | format-table -View Application The output from Get-WindowTime is no different than any other type of object in PowerShell which means you can export to a CSV or XML format, save to a text file or anything else. These commands only work for the current and local interactive user. ALIASES The module contains the following aliases: gfwp --> Get-ForegroundWindowProcess gwt --> Get-Windowtime mwt --> Measure-WindowTotal gwts --> Get-WindowTimeSummary IMPORTING AND EXPORTING It is recommended that you use the XML format to export and import work history. PS C:\> $data | export-clixml C:\work\8-25-15-work.xml The XML format will preserve property type. Before using any imported data, be sure to import this module first. This will properly format and display the imported data and allow you to measure it. KNOWN ISSUES Occassionally, you may see a result like this: Time : 00:00:00.2095710 Application : {Google Chrome, Thunderbird} WindowTitle : Hootsuite - Google Chrome Mozilla Thunderbird Product : {Google Chrome, Thunderbird} This appears to be the result of task switching with either Alt+Tab or Ctrl+Tab. For the most part, the time spent is in milleseconds and thus can be ignored. SEE ALSO Get-Process