$Output = "$Home\Desktop\Colors.txt" # ------------------------------------------------------------------------------------------------------------ $Code = @' [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern short GetAsyncKeyState(int virtualKeyCode); '@ Add-Type -MemberDefinition $Code -Name Keys -Namespace Capture Add-Type -As System.Windows.Forms [console]::CursorVisible = $false $Pix = New-Object System.Drawing.Bitmap 1,1 $*** = [system.drawing.graphics]::FromImage($Pix) $Empty = [System.Drawing.Point]::Empty $Conf = @{} # ------------------------------------------------------------------------------------------------------------ function Get-CButton { do { $pressed = [bool]([Capture.Keys]::GetAsyncKeyState(67) -eq -32767) if ([bool]([Capture.Keys]::GetAsyncKeyState(27) -eq -32767)) {Return 1} } until ($pressed -or $stop) Return 0 } # ------------------------------------------------------------------------------------------------------------ write-host "`nOutput: '$Output'`n" write-host -f yellow "--- Capture Colors with [C]-Button ; [Esc]-Button to end capturing ---`n" do { $val = Get-CButton if (!$val) { $***.CopyFromScreen([system.windows.forms.cursor]::position,$Empty,'1,1') [string[]]$Colors += [system.drawing.colortranslator]::ToHtml($Pix.GetPixel(0,0)) write-host -f 'gray' $Colors[-1] } } until ($Val) # ------------------------------------------------------------------------------------------------------------ $Colors | Out-File $Output