AutoHotKey -Windows 将图像从网站复制到剪贴板

AutoHotKey -Windows Copy an image from a website to clipboard

我想看看是否有某种方法可以将网站上的图像复制到剪贴板中,以便将其保存在画图中。或者只是简单地将图像保存到画图中。我可以通过 id 访问网站和 select 元素。但是在我获得 id selected 之后,我不知道如何将它复制到剪贴板或保存它。我正在尝试不必通过单击鼠标右键自动热键并向下滚动以保存图像。如果需要,我准备好,但要确保没有其他选择。除此之外还有其他选择吗?

myImage := img.document
myImage.getElementById("image")

javascript clipboardData object (see also) 仅在用户触发了 copy/paste 事件时才有效。示例:如果从网站复制内容到剪贴板,则可以编辑复制的内容。

在 AutoHotKey 上你可以这样做:

1- 使用 RegExMatch() 从 HTML 代码中获取图像 URL(s)。

2- 使用 UrlDownloadToFile, URL, Filename 将图像保存到文件中。

获取网站的第一个 PNG 图片的示例:

FileDelete, source.html ;clear previous tests (if any)
UrlDownloadToFile, http://www.freestock.tk, source.html ;copy the html code to your PC
Recheck:
if FileExist("source.html") ;check if the html code was downloaded already
{
FileRead, sourcevar, source.html ;pass the html code into a variable
Position := RegExMatch(sourcevar, "is)images/(.*?).png", imagename) ; search for a image pattern 
picurl:= "http://www.freestock.tk/images/" imagename1 ".png" ; build the complete pic url 
picname:= imagename1 ".png" ; build the complete pic name
UrlDownloadToFile, %picurl%, %picname% ; save the picture into a file
}
else
{
Sleep, 5000
goto, Recheck   
}
return

ps:代码已测试并正常工作。