Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.1 KB

File metadata and controls

34 lines (25 loc) · 1.1 KB

PowerShell GUI Bridge

This project demonstrates a cross platform way to do graphical user interface actions from powershell. It achieves this by establishing a bidirectional json encoded channel to a GUI executable (built using Avalonia) that can execute the requested GUI actions.

The demo script (demo.ps1) shows how to call open and save file dialogs from powershell. I've tested this on Windows and Linux. (MacOS should also work, but I don't have that hardware)

Implemented dialogs

  • Invoke-FolderPickerDialog
  • Invoke-OpenFileDialog
  • Invoke-SaveFileDialog

Example

using module .\GUICommands.psd1

try
{
    $GUIBridge = New-GUIBridge

    $imageFileFilters = @( 
        @{ Name = 'Images'; Extensions = @('*.jpg', '*.jpeg', '*.bmp') },
        @{ Name = 'All Files'; Extensions = @('*.*') }
    )

    $imageFiles = Invoke-OpenFileDialog -bridge $GUIBridge -title "Open image file" -suggestedStartLocation $HOME -allowMultiple $true -filters $imageFileFilters
    "selected image files: $imageFiles"
}
finally
{
    Close-GUIBridge -bridge $GUIBridge
}