Advertisement
iwishportalwasreal

ConvertToUPPERCASE-01.ps1

May 22nd, 2024 (edited)
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 2.24 KB | Source Code | 0 0
  1. <#
  2. 2024-05-22 Wed. 9:15a.
  3. ConvertToUPPERCASE-01.ps1
  4. https://github.com/EverythingIsCodeCodeCode/public_GitHub_data/blob/main/ConvertToUPPERCASE-01.ps1
  5. https://pastebin.com/FSJWJPm8
  6. Made with ChatGPT.
  7. This PowerShell script will make a GUI window that lets people convert text to UPPERCASE.  To make a desktop icon shortcut, modify it to something similar to the line below:
  8. powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Path\To\Your\Script\UppercaseConverter.ps1"
  9. It doesn't require Internet access.  The URIs are part of the standard .NET framework and are recognized by the XAML parser to render the GUI elements correctly.
  10. #>
  11.  
  12. Add-Type -AssemblyName PresentationFramework
  13.  
  14. [xml]$xaml = @"
  15. <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  16.        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  17.        Title="Uppercase Converter" Height="350" Width="400">
  18.    <Grid>
  19.        <TextBox Name="InputTextBox" Height="120" Margin="10,10,10,200" VerticalScrollBarVisibility="Auto" AcceptsReturn="True"/>
  20.        <Button Name="ConvertButton" Content="Convert to Uppercase" Width="150" Height="40" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,50"/>
  21.        <TextBox Name="OutputTextBox" Height="120" Margin="10,140,10,90" VerticalScrollBarVisibility="Auto" IsReadOnly="True"/>
  22.        <TextBlock Name="ClipboardStatus" Height="20" Margin="10,0,10,20" VerticalAlignment="Bottom" HorizontalAlignment="Center" TextAlignment="Center"/>
  23.    </Grid>
  24. </Window>
  25. "@
  26.  
  27. # Load the XAML
  28. $reader = (New-Object System.Xml.XmlNodeReader $xaml)
  29. $window = [Windows.Markup.XamlReader]::Load($reader)
  30.  
  31. # Define the event handler for the button click
  32. $convertToUppercase = {
  33.     $inputText = $window.FindName("InputTextBox").Text
  34.     $outputText = $inputText.ToUpper()
  35.     $window.FindName("OutputTextBox").Text = $outputText
  36.  
  37.     # Copy the converted text to the clipboard
  38.     [System.Windows.Clipboard]::SetText($outputText)
  39.     $window.FindName("ClipboardStatus").Text = "Text copied to clipboard!"
  40. }
  41.  
  42. # Attach the event handler to the button click event
  43. $convertButton = $window.FindName("ConvertButton")
  44. $convertButton.Add_Click($convertToUppercase)
  45.  
  46. # Show the window
  47. $window.ShowDialog() | Out-Null
  48.  
Tags: powershell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement