### Install XAMLgui Module Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Installs the XAMLgui module from the PowerShell gallery. Ensure you have an active internet connection. ```powershell Install-Module -name XAMLgui ``` -------------------------------- ### Start Await Job with InitBlock Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Initiates a job that can be awaited, with support for an initialization block. The InitBlock can be constructed using Get-FnAsString. ```powershell Start-AwaitJob -InitBlock (@( Get-FnAsString "fn1", Get-FnAsString "fn2" ) -Join "`n") ``` -------------------------------- ### Download XAMLgui Module Locally Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Saves the XAMLgui module to the current directory without installing it globally. This creates a subfolder for the module. ```powershell Save-Module -Name XAMLgui -Path .\ ``` -------------------------------- ### Add Type Assembly Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Example of adding types from System.Drawing and System.Windows.Forms assemblies, as mentioned in v1.1.5. ```powershell Add-Type -AssemblyName System.Drawing,System.Windows.Forms ``` -------------------------------- ### Module Management Functions Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Functions for finding, getting, and importing local modules. ```APIDOC ## Find-LocalModulePath ### Description Find the path of a module in the current directory. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters - **Name** (string) - Required - The name of the module. - **Path** (String) - Optional - The base path to search in. Defaults to ".\ps-modules". ### Request Example ```powershell Find-LocalModulePath -Name "MyModule" ``` ### Response - **string** - The path to the module if found. ``` ```APIDOC ## Get-LocalModule ### Description Get the path of a module in the current directory if it exists, otherwise download it and return its path. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters - **Name** (string) - Required - The name of the module. - **Path** (String) - Optional - The base path to search in. Defaults to ".\ps-modules". - **Download** (Boolean) - Optional - Whether to download the module if not found. Defaults to $True. ### Request Example ```powershell Get-LocalModule -Name "MyModule" -Download $true ``` ### Response - **string** - The path to the module. ``` ```APIDOC ## Import-LocalModule ### Description Import a module from the current directory's `\ps-module` folder. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters - **Name** (string) - Required - The name of the module. - **Path** (String) - Optional - The base path to search in. Defaults to ".\ps-modules". - **Download** (Boolean) - Optional - Whether to download the module if not found. Defaults to $True. ### Request Example ```powershell Import-LocalModule -Name "MyModule" ``` ### Response None ``` ```APIDOC ## Set-LocalModulePathBase ### Description Use to set the a default path for LocalModule commands. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters - **Path** (string) - Required - The base path for local modules. ### Request Example ```powershell Set-LocalModulePathBase -Path "C:\Modules" ``` ### Response None ``` -------------------------------- ### Start Await Job Arguments Type Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Ensures the -Arguments parameter for Start-AwaitJob is of the correct Object[] type. This was a fix in v1.1.4. ```powershell Start-AwaitJob -Arguments ``` -------------------------------- ### Start and Wait for AwaitJob Source: https://context7.com/bananaacid/xamlgui/llms.txt Runs long-running operations in background jobs, keeping the UI responsive. Supports synchronous blocking and asynchronous execution with optional initialization blocks and working directories. Requires XAMLgui module import. ```powershell Import-Module -Name XAMLgui # Synchronous background job (blocks but keeps UI responsive) $result = Start-AwaitJob -ScriptBlock { param($url) Invoke-WebRequest -Uri $url -UseBasicParsing return "Download complete" } -ArgumentList @("https://example.com/data.json") Write-Host $result ``` ```powershell # Asynchronous background job $job = Start-AwaitJob -ScriptBlock { Start-Sleep -Seconds 5 return "Long operation finished" } -Await $False # Do other work while job runs... Write-Host "Job started, continuing with other work..." # Wait for completion when ready $result = Wait-AwaitJob $job Write-Host $result ``` ```powershell # Job with working directory and initialization block $result = Start-AwaitJob -ScriptBlock { Get-ChildItem | Select-Object Name } -Dir "C:\Projects" -InitBlock "Import-Module MyModule" ``` -------------------------------- ### Get File Icon Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Retrieves an icon from a file, suitable for window icons or notification bubbles. ```powershell Get-IconFromFile ``` -------------------------------- ### Get XAMLgui Version Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Retrieves the version of the XAMLgui module. Useful when files are loaded directly without importing the module. ```powershell Get-XAMLguiVersion ``` -------------------------------- ### Get Function as String Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Useful for dynamically generating script blocks, particularly for functions like Start-AwaitJob. Ensure functions are defined before calling this. ```powershell Get-FnAsString ``` -------------------------------- ### Get Local Module Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Downloads a module if it's not present and returns its path. In v1.1.4, it was updated to use the '\ps-modules' subfolder. ```powershell Get-LocalModule ``` -------------------------------- ### Get Known Events Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Lists events that are recognized by XAMLgui. In v1.1.7, more events were added, and Add-KnownEventsByControlName was introduced. ```powershell Get-KnownEvents ``` -------------------------------- ### Get PowerShell Interpreter Path Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Retrieves the current PowerShell executable path and checks for the availability of 'powershell.exe' or 'pwsh.exe'. ```powershell Get-PowershellInterpreter ``` -------------------------------- ### Initialize and Display Window Source: https://context7.com/bananaacid/xamlgui/llms.txt Loads a XAML file to generate UI elements and the window object, then displays the window. ```PowerShell $Elements, $Window = . New-Window ".\MainWindow.xaml" -Debug # Show main window $Window | Show-Window ``` -------------------------------- ### Initialize Application Workflow Source: https://context7.com/bananaacid/xamlgui/llms.txt Sets up the application environment by hiding the console and enabling visual styles. ```powershell Import-Module -Name XAMLgui # Hide console for clean GUI experience Hide-Console | Out-Null Enable-VisualStyles ``` -------------------------------- ### Set-RunOnce Source: https://context7.com/bananaacid/xamlgui/llms.txt Configures a script to run automatically at next Windows startup using the RunOnce registry key. ```APIDOC ## Set-RunOnce ### Description Configures a script to run automatically at next Windows startup using the RunOnce registry key. ### Method POST ### Endpoint N/A (Function within a module) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **KeyName** (string) - Required - A unique name for the RunOnce entry. - **Command** (string) - Optional - The command to execute. Defaults to the current script. - **Params** (string) - Optional - Parameters to pass to the command. - **Interpreter** (string) - Optional - The path to the interpreter (e.g., PowerShell.exe). ### Request Example ```powershell # Run current script at next startup Set-RunOnce -KeyName "MyAppSetup" # Run a specific script with custom command Set-RunOnce -KeyName "ConfigureSystem" ` -Command "-executionpolicy bypass -file `"C:\Setup\configure.ps1`"" ` -Params "-Silent" # Specify PowerShell interpreter explicitly Set-RunOnce -KeyName "UpdateCheck" ` -Command "-file `"C:\MyApp\update.ps1`"" ` -Interpreter "C:\Program Files\PowerShell\7\pwsh.exe" ``` ### Response #### Success Response (200) - **Status** (string) - Indicates success or failure of setting the RunOnce key. #### Response Example ```json { "Status": "Success" } ``` ``` -------------------------------- ### Get Write Error Clean Mode Source: https://github.com/bananaacid/xamlgui/blob/main/README.md Retrieves the current mode for Write-ErrorClean. This function was added in v1.1.6. ```powershell Get-WriteErrorCleanMode ``` -------------------------------- ### Configure RunOnce Registry Keys Source: https://context7.com/bananaacid/xamlgui/llms.txt Schedules scripts to run at the next Windows startup. ```powershell Import-Module -Name XAMLgui # Run current script at next startup Set-RunOnce -KeyName "MyAppSetup" # Run a specific script with custom command Set-RunOnce -KeyName "ConfigureSystem" ` -Command "-executionpolicy bypass -file `"C:\Setup\configure.ps1`"" ` -Params "-Silent" # Specify PowerShell interpreter explicitly Set-RunOnce -KeyName "UpdateCheck" ` -Command "-file `"C:\MyApp\update.ps1`"" ` -Interpreter "C:\Program Files\PowerShell\7\pwsh.exe" # Get current interpreter info $current, $available = Get-PowershellInterpreter Write-Host "Current: $current" Write-Host "Available: $($available | ConvertTo-Json)" ``` -------------------------------- ### Create a window from a XAML file Source: https://context7.com/bananaacid/xamlgui/llms.txt Loads a WPF window from a local file and binds event handlers using the naming convention WindowClass.ElementEventName. ```powershell Import-Module -Name XAMLgui # Define event handler using naming convention: WindowClass.ElementEventName function ProjectTest1.MainWindow.btnSubmit_Click($Sender, $EventArgs) { Show-MessageBox "Button was clicked!" } # Load window from XAML file (dot-source to enable handler binding) $Elements, $MainWindow = . New-Window ".\MainWindow.xaml" -Debug # Access named elements directly $Elements.txtUsername.Text = "DefaultUser" $Elements.lvItems.ItemsSource = @("Item1", "Item2", "Item3") # Display the window as a modal dialog $MainWindow | Show-Window ``` -------------------------------- ### Create a window from a XAML string Source: https://context7.com/bananaacid/xamlgui/llms.txt Initializes a window directly from a XAML string, useful for dynamic UI generation. ```powershell Import-Module -Name XAMLgui $xamlContent = @"