我在这里看到了一个类似CLIP的工具Clip命令,但它可以在剪贴板中使用,而不能在其他方向使用。
我已经看到了对“粘贴”的引用,但这似乎不是Windows的一部分。我需要找到适用于标准w7 w8 w10环境的解决方案。
剪辑已分发。是否有人从剪贴板到文件都可以使用的工具?
编辑似乎可以使用powershell命令进行操作
我刚刚编写的C#程序可以完成Powershell的操作
class Clip2File
{
[STAThread()]
static void Main(string[] args)
{
var fileName = @"c:\demo.png";
if (args.Length != 0){
fileName = args[0];
}
if (!Clipboard.ContainsImage()) return;
Image img = Clipboard.GetImage();
img?.Save(fileName, ImageFormat.Png);
}
}
Windows cmd
(如果剪贴板包含文本数据):
Powershell -command Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.Clipboard]::GetText()
示例显示了上面的命令将两个字节添加到输出(Cr和Lf):
==> >1049363a.txt echo first line
==> >>1049363a.txt echo 2nd line
==> clip<1049363a.txt
==> >1049363b.txt Powershell -command Add-Type -AssemblyName System.Windows.Forms;[System.W
indows.Forms.Clipboard]::GetText()
==> findstr /N "^" 1049363*.txt
1049363a.txt:1:first line
1049363a.txt:2:2nd line
1049363b.txt:1:first line
1049363b.txt:2:2nd line
1049363b.txt:3:
==> dir 1049363*.txt |find ".txt"
06.03.2016 17:24 22 1049363a.txt
06.03.2016 17:24 24 1049363b.txt
==>
阅读有关.NET Framework Clipboard类方法的更多信息。
编辑答案扩展主题(保存图像,请参阅ImageFormat Class):
Add-Type -AssemblyName System.Windows.Forms ### not necessary in PowerShell_ISE
if ($([System.Windows.Forms.Clipboard]::ContainsImage())) {
$image = [System.Windows.Forms.Clipboard]::GetImage()
$filename='d:\test\test.png' ### edit to fit in your circumstances
[System.Drawing.Bitmap]$image.Save($filename,
[System.Drawing.Imaging.ImageFormat]::Png)
Write-Output "clipboard content saved as $filename"
} else {
Write-Output "clipboard does not contains image data"
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句