BurntToast PowerShell Module

repository·main·Indexed 26 days ago

https://github.com/windos/burnttoast

A PowerShell module for displaying Windows Toast Notifications on Windows 10 and Windows Server 2019 or later. It provides functions to create interactive notifications with buttons, text inputs, audio, and progress bars, as well as tools to manage notification history and headers. Note: This project is no longer maintained and the repository is archived.

Tokens
13.4K
Snippets
44
Records
59
Agent score
81%

What's inside BurntToast

  1. Overview of BurntToast

    main

    BurntToast is a PowerShell module designed for displaying Toast Notifications on Windows 10 and Windows Server 2019 and above.

    Note: BurntToast is no longer maintained. The repository is archived, and there will be no further updates, bug fixes, or support. Users are encouraged to fork the project if they wish to continue development.

  2. Identify the Microsoft.Toolkit.Uwp.Notifications dependency

    main

    BurntToast relies on the Microsoft.Toolkit.Uwp.Notifications library to handle Windows Toast Notifications. This library is available via NuGet and provides the underlying implementation for notification features. Depending on your target framework, you may need to reference the appropriate library directory:

    • For .NET Framework 4.6.1: \lib\net461
    • For .NET 5.0+ (Windows 10 17763+): \lib\net5.0-windows10.0.17763
  3. Configure Determinate and Indeterminate progress bars

    main

    You can choose between two modes for the progress bar:

    1. Determinate (Percentage-based): Provide a Value between 0 and 1. You can optionally use -ValueDisplay to show a custom label instead of the percentage.

      # 20% complete with custom label
      New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete'
    2. Indeterminate (Animated): Use the -Indeterminate switch to show a continuous animation. This mode cannot be used with the -Value parameter.

      New-BTProgressBar -Status 'Copying files' -Indeterminate
    # Determinate example
    New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete'
    
    # Indeterminate example
    New-BTProgressBar -Status 'Copying files' -Indeterminate
  4. Include a progress bar in a toast binding

    main

    You can include a progress bar in your notification by creating a progress bar object with New-BTProgressBar and passing it to the -Children parameter of New-BTBinding.

    $progress = New-BTProgressBar -Title 'Updating' -Status 'Running' -Value 0.4
    $binding = New-BTBinding -Children $progress
  5. Examples of New-BTButton usage

    main

    Various ways to implement buttons in BurntToast notifications:

    System Dismiss Button

    New-BTButton -Dismiss

    System Snooze Button (Default)

    New-BTButton -Snooze

    Custom Snooze Button with Selection Box ID

    New-BTButton -Snooze -Content 'Sleep' -Id 'TimeSelection'

    Standard URL Button

    New-BTButton -Content 'Blog' -Arguments 'https://king.geek.nz'

    Button with Image Icon

    $pic = 'C:\temp\example.png'
    New-BTButton -Content 'View Picture' -Arguments $pic -ImageUri $pic

    Styled Success (Green) Button

    New-BTButton -Content 'Approve' -Arguments 'approve' -Color Green

    Styled Critical (Red) Button

    New-BTButton -Content 'Delete' -Arguments 'delete' -Color Red
  6. Combine buttons and context menu items

    main

    You can create an action set that includes both a visible clickable button and a right-click context menu item by passing both to the -Buttons and -ContextMenuItems parameters.

    $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com'
    $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com'
    New-BTAction -Buttons $Button -ContextMenuItems $ContextMenuItem
  7. Create a side-by-side layout using multiple columns

    main

    To create a side-by-side layout in a notification, create multiple column objects using New-BTColumn and assign them different -Weight values. The Weight determines the relative width of each column. You then pass these columns to the -Column parameter of New-BTBinding.

    $labels = New-BTText -Text 'Title:' -Style Base
    $values = New-BTText -Text 'Example' -Style BaseSubtle
    $col1 = New-BTColumn -Children $labels -Weight 4
    $col2 = New-BTColumn -Children $values -Weight 6
    New-BTBinding -Column $col1, $col2