Auto-commit: 2025-10-31 08:58:35
This commit is contained in:
BIN
Tools/PS2EXE-GUI/Examples/Basisdemo.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Basisdemo.ps1
Normal file
Binary file not shown.
BIN
Tools/PS2EXE-GUI/Examples/Choice.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Choice.ps1
Normal file
Binary file not shown.
BIN
Tools/PS2EXE-GUI/Examples/Confirm.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Confirm.ps1
Normal file
Binary file not shown.
14
Tools/PS2EXE-GUI/Examples/Get-ScriptPath.ps1
Normal file
14
Tools/PS2EXE-GUI/Examples/Get-ScriptPath.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
# Example script to retrieve path to script
|
||||
|
||||
# When compiled with PS2EXE the variable MyCommand contains no path anymore
|
||||
|
||||
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript")
|
||||
{ # Powershell script
|
||||
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
|
||||
}
|
||||
else
|
||||
{ # PS2EXE compiled script
|
||||
$ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
|
||||
}
|
||||
|
||||
"Directory of executable file: " + $ScriptPath
|
||||
BIN
Tools/PS2EXE-GUI/Examples/Output.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Output.ps1
Normal file
Binary file not shown.
BIN
Tools/PS2EXE-GUI/Examples/Parameter.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Parameter.ps1
Normal file
Binary file not shown.
23
Tools/PS2EXE-GUI/Examples/Process-Pipeline.ps1
Normal file
23
Tools/PS2EXE-GUI/Examples/Process-Pipeline.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# Example script to process pipeline
|
||||
|
||||
# Type of pipeline object gets lost for compiled scripts, pipeline objects are always strings
|
||||
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[parameter(Mandatory=$FALSE, ValueFromPipeline=$TRUE)] [AllowEmptyString()]$Pipeline
|
||||
)
|
||||
BEGIN
|
||||
{
|
||||
"Reading pipeline as array of strings"
|
||||
$COUNTER = 0
|
||||
}
|
||||
PROCESS
|
||||
{
|
||||
if ($Pipeline -eq $NULL)
|
||||
{ Write-Output "No element found in the pipeline" }
|
||||
else
|
||||
{
|
||||
$COUNTER++
|
||||
Write-Output "$COUNTER`: $Pipeline"
|
||||
}
|
||||
}
|
||||
13
Tools/PS2EXE-GUI/Examples/Progress.ps1
Normal file
13
Tools/PS2EXE-GUI/Examples/Progress.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
# demo program for Write-Progress
|
||||
|
||||
1..10 | % { Write-Progress -Activity "Activity $_" -Status "State $_" -Id 1 -CurrentOperation "Operation $_" -PercentComplete ([int]10*$_) -SecondsRemaining (10-$_) ;
|
||||
Start-Sleep 1 }
|
||||
|
||||
Start-Sleep 3
|
||||
Write-Progress -Activity "Activity" -Status "State" -Id 1 -Completed
|
||||
Write-Host "Completed"
|
||||
Start-Sleep 1
|
||||
|
||||
Write-Progress -Activity "New progress" -Status "New state" -PercentComplete 33 -SecondsRemaining 734
|
||||
Start-Sleep 3
|
||||
Write-Output "Exiting program"
|
||||
10
Tools/PS2EXE-GUI/Examples/ReadKey.ps1
Normal file
10
Tools/PS2EXE-GUI/Examples/ReadKey.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
"ReadKey-Demo`n`nWait for KeyDown event first, then for KeyUp-Event`n(only in KeyUp event modification keys are visible)"
|
||||
|
||||
$Host.UI.RawUI.ReadKey("IncludeKeyDown,NoEcho")
|
||||
|
||||
Read-Host "`nAfter pressing Enter there will a pause of two seconds before waing for the KeyUp event"
|
||||
sleep 2
|
||||
|
||||
$Host.UI.RawUI.ReadKey("IncludeKeyUp")
|
||||
|
||||
if ($Host.UI.RawUI.KeyAvailable) { "Key in key buffer found" } else { "No key in key buffer found" }
|
||||
85
Tools/PS2EXE-GUI/Examples/ScreenBuffer.ps1
Normal file
85
Tools/PS2EXE-GUI/Examples/ScreenBuffer.ps1
Normal file
@@ -0,0 +1,85 @@
|
||||
# Example script for screen operations
|
||||
|
||||
function Get-CharFromConsolePosition([int]$X, [int]$Y)
|
||||
{ # function to get the character of a position in the console buffer
|
||||
$RECT = New-Object System.Management.Automation.Host.Rectangle $X, $Y, $X, $Y
|
||||
$host.UI.RawUI.GetBufferContents($RECT)[0,0]
|
||||
}
|
||||
|
||||
|
||||
# fill block with a character
|
||||
$BufferCell = New-Object System.Management.Automation.Host.BufferCell "O", "White", "Red", "Complete"
|
||||
# Complete - The character occupies one BufferCell structure.
|
||||
# Leading - The character occupies two BufferCell structures, with this cell being the leading cell (UNICODE)
|
||||
# Trailing - The character occupies two BufferCell structures, with this cell being the trailing cell (UNICODE)
|
||||
$Source = New-Object System.Management.Automation.Host.Rectangle 10, 10, 29, 29
|
||||
|
||||
$host.UI.RawUI.SetBufferContents($Source, $BufferCell)
|
||||
|
||||
|
||||
# read block into buffer
|
||||
$ScreenBuffer = New-Object -TypeName 'System.Management.Automation.Host.BufferCell[,]' -ArgumentList ($Source.Bottom - $Source.Top + 1),($Source.Right - $Source.Left + 1)
|
||||
$ScreenBuffer = $host.UI.RawUI.GetBufferContents($Source)
|
||||
|
||||
|
||||
# modify block in buffer
|
||||
$MAXDIMENSION = [Math]::Min(($Source.Bottom - $Source.Top + 1),($Source.Right - $Source.Left + 1))
|
||||
for ($COUNTER = 0; $COUNTER -lt $MAXDIMENSION; $COUNTER++)
|
||||
{
|
||||
$ScreenBuffer[$COUNTER,$COUNTER] = New-Object System.Management.Automation.Host.BufferCell "X", "White", "Red", "Complete"
|
||||
$ScreenBuffer[($MAXDIMENSION - $COUNTER - 1),$COUNTER] = New-Object System.Management.Automation.Host.BufferCell "X", "White", "Red", "Complete"
|
||||
}
|
||||
|
||||
|
||||
# write back buffer to screen
|
||||
$host.UI.RawUI.SetBufferContents((New-Object System.Management.Automation.Host.Coordinates $Source.Left, $Source.Top), $ScreenBuffer)
|
||||
|
||||
|
||||
# move block
|
||||
# define fill character for source range
|
||||
$BufferCell.Character = "-"
|
||||
$BufferCell.ForegroundColor = $host.UI.RawUI.ForegroundColor
|
||||
$BufferCell.BackgroundColor = $host.UI.RawUI.BackgroundColor
|
||||
# define clipping area (a ten character wide border)
|
||||
$Clip = New-Object System.Management.Automation.Host.Rectangle 10, 10, ($host.UI.RawUI.WindowSize.Width - 10), ($host.UI.RawUI.WindowSize.Height - 10)
|
||||
|
||||
# repeat ten times
|
||||
for ($i = 1; $i -le 10; $i++)
|
||||
{
|
||||
for ($X = $Source.Left + 1; $X -le ($host.UI.RawUI.WindowSize.Width - $Source.Right + $Source.Left); $X++)
|
||||
{
|
||||
$Destination = New-Object System.Management.Automation.Host.Coordinates $X, 10
|
||||
$host.UI.RawUI.ScrollBufferContents($Source, $Destination, $Clip, $BufferCell)
|
||||
$Source.Right++
|
||||
$Source.Left++
|
||||
}
|
||||
|
||||
for ($Y = $Source.Top + 1; $Y -le ($host.UI.RawUI.WindowSize.Height - $Source.Bottom + $Source.Top); $Y++)
|
||||
{
|
||||
$Destination = New-Object System.Management.Automation.Host.Coordinates $Source.Left, $Y
|
||||
$host.UI.RawUI.ScrollBufferContents($Source, $Destination, $Clip, $BufferCell)
|
||||
$Source.Bottom++
|
||||
$Source.Top++
|
||||
}
|
||||
|
||||
for ($X = $Source.Left - 1; $X -ge 10; $X--)
|
||||
{
|
||||
$Destination = New-Object System.Management.Automation.Host.Coordinates $X, $Source.Top
|
||||
$host.UI.RawUI.ScrollBufferContents($Source, $Destination, $Clip, $BufferCell)
|
||||
$Source.Right--
|
||||
$Source.Left--
|
||||
}
|
||||
|
||||
for ($Y = $Source.Top - 1; $Y -ge 10; $Y--)
|
||||
{
|
||||
$Destination = New-Object System.Management.Automation.Host.Coordinates $Source.Left, $Y
|
||||
$host.UI.RawUI.ScrollBufferContents($Source, $Destination, $Clip, $BufferCell)
|
||||
$Source.Bottom--
|
||||
$Source.Top--
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# get character from screen
|
||||
"Character at position (10/10): "
|
||||
Get-CharFromConsolePosition 10 10
|
||||
BIN
Tools/PS2EXE-GUI/Examples/Winformsdemo.ps1
Normal file
BIN
Tools/PS2EXE-GUI/Examples/Winformsdemo.ps1
Normal file
Binary file not shown.
Reference in New Issue
Block a user