Skip to content

Use multiplatform gui features from powershell (windows linux and osx)

License

Notifications You must be signed in to change notification settings

jpmikkers/PowerShellGUIBridge

Repository files navigation

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
}

About

Use multiplatform gui features from powershell (windows linux and osx)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published