Last active
December 19, 2015 19:48
-
-
Save tmplinshi/6008649 to your computer and use it in GitHub Desktop.
Copy local image or web image to clipboard.
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
#NoEnv | |
#SingleInstance force | |
#Include <WinClipAPI> ; http://www.autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/ | |
#Include <WinClip> | |
SetBatchLines, -1 | |
f1:: | |
InputBox, ImageFile, Copy image to clipboard, Please input image path`, or image url:,, 500, 120 | |
if ErrorLevel | |
Return | |
CopyImg(ImageFile) | |
ToolTip, % "`n`n" A_Tab "Copied!" A_Tab A_Tab "`n`n" | |
Sleep, 2000 | |
ToolTip | |
Return | |
CopyImg(ImageFile) | |
{ | |
; Expand to full path | |
if !RegExMatch(ImageFile, "i)^(https?|ftp)://") | |
{ | |
Loop, %ImageFile% | |
ImageFile := A_LoopFileLongPath | |
} | |
html = | |
(LTrim | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
<HTML><HEAD></HEAD> | |
<BODY><!--StartFragment--><IMG src="%ImageFile%"><!--EndFragment--></BODY> | |
</HTML> | |
) | |
WinClip.Clear() | |
WinClip.SetHTML( html ) | |
if RegExMatch(ImageFile, "i)^(https?|ftp)://") | |
return | |
WinClip.SetFiles( ImageFile ) | |
WinClip.SetBitmap( ImageFile ) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment