- <#
- .SYNOPSIS
- This script displays the Windows Color dialog box, then
- displays the r, g, b values of the colours selected
- .DESCRIPTION
- This script calls windows.forms to show the color dialog. You then
- select a colour, and hit OK. The script then displays the values you selected.
- .NOTES
- File Name : Get-ColourRGB.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/09/get-colourrgbps1.html
- #>
- # Define worker function
- function Get-ColourRGB {
- param(
- $R = 0, # Red value
- $G = 0, # Green value
- $B = 0 # Blue value
- )
- # Show colour dialog, get colour
- $colorDialog = New-Object Windows.Forms.ColorDialog -Property @{
- FullOpen = $true
- Color = [Drawing.Color]::FromArgb($R,$G,$B)
- }
- if ($colorDialog.ShowDialog() -eq "OK") {
- $R = $colordialog.color.R
- $G = $colordialog.color.G
- $B = $colordialog.color.B
- $R;$G;$B
- }
- }
- # Call the worker function
- $R1,$G1,$B1 = Get-ColourRGB 128 128 128
- # Describe
- " You set:"
- " R to: {0}" -f $R1
- " G to: {0}" -f $G1
- " B to: {0}" -f $B1
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Saturday, 18 September 2010
Get-ColourRGB.ps1
Labels:
ColorDialog,
powershell,
PowerShell scripts,
Windows.Forms
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment