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)
Invoke-FolderPickerDialogInvoke-OpenFileDialogInvoke-SaveFileDialog
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
}