Created
May 27, 2012 14:01
-
-
Save tkmtmkt/2814331 to your computer and use it in GitHub Desktop.
クリップボード内の画像をファイルに保存する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
クリップボート内の画像をファイルに出力します。 | |
#> | |
Function cap | |
{ | |
powershell -sta -command { | |
Add-Type -AssemblyName System.Windows.Forms | |
$cb = [Windows.Forms.Clipboard] | |
$img = $cb::GetImage() | |
if ($img -ne $null) { | |
$images = "$Home\images" | |
If(-not (Test-Path $images)) { | |
New-Item $images -ItemType Directory -Force | Out-Null | |
} | |
[int]$fileno = ls $images | ?{$_.Name -match 'img(\d{3}).png'} | | |
sort | select -last 1 | %{$Matches[1]} | |
$out_file = "$images\img{0:000}.png" -f ($fileno + 1) | |
$img.Save($out_file) | |
$out_file | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment