kiu-clipsave
3.5 KB only
and a code like this
Send,!{PrintScreen} Sleep,1000 RunWait, kiu-clipsave.exe, , Hide Sleep,1000 SplashImage, image.jpg, B2 KeyWait, LButton, down return
Send,!{PrintScreen} Sleep,1000 RunWait, kiu-clipsave.exe, , Hide Sleep,1000 SplashImage, image.jpg, B2 KeyWait, LButton, down return
you can't save to a file a picture in the clipboard without an external program.
/* * User: kiu - Salvatore Agostino Romeo * Date: 02/02/2006 * Time: 13.05 * e-mail: [email protected] * */ using System; using System.Windows.Forms; using System.Drawing; namespace DefaultNamespace { /// <summary> /// Save images from clipboard. /// </summary> public class GetClip { public static void Main() { if (Clipboard.GetDataObject() != null) { IDataObject data = Clipboard.GetDataObject(); if (data.GetDataPresent(DataFormats.Bitmap)) { Image image = (Image)data.GetData(DataFormats.Bitmap,true); image.Save("image.png",System.Drawing.Imaging.ImageFormat.Png); image.Save("image.jpg",System.Drawing.Imaging.ImageFormat.Jpeg); } } } } }
image.Save("image.png",System.Drawing.Imaging.ImageFormat.Bmp);will allow to save to bmp, and it is possible to save to gif (and others maybe) too. Let me know if you are interested in other format outputs
kiu doesn't like IrfanView (why? just curiosity)
; Save any bitmaps on the clipboard to file ; isolated by [email protected] from Sean's script "ScreenCapture.ahk" posted on ; http://www.autohotkey.com/forum/topic18146.html ; needs GDI+ libaray "gdiplus.dll" which can be obtained from ; http://www.microsoft.com/downloads/details.aspx?FamilyID=6a63ab9c-df12-4d41-933c-be590feaa05a&displaylang=en SaveClipBoardToJPG() ; example SaveClipBoardToBMP() ; example SaveClipBoardToBMP() { Convert("", "clip.bmp") } SaveClipBoardToJPG() { Convert("", "clip.jpg") } Convert(sFileFr = "", sFileTo = "") { If sFileTo = sFileTo := A_ScriptDir . "\screen.bmp" SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll") Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : "" VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) If !sFileFr { DllCall("OpenClipboard", "Uint", 0) If DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2)) { DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage) } DllCall("CloseClipboard") } Else If (sFileFr Is Integer) { DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage) } Else { DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage) } DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize) VarSetCapacity(ci, nSize) DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci) Loop, %nCount% { If !InStr(Ansi4Unicode(NumGet(ci, 76 * (A_Index - 1) + 44)), "." . sExtTo) Continue pCodec := &ci + 76 * (A_Index - 1) Break } If pImage pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", 0) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken) DllCall("FreeLibrary", "Uint", hGdiPlus) } SaveHBITMAPToFile(hBitmap, sFile) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0) DllCall("CloseHandle", "Uint", hFile) } Unicode4Ansi(ByRef wString, sString) { nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0) VarSetCapacity(wString, nSize * 2) DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize) Return &wString } Ansi4Unicode(pString) { nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0) Return sString } SetClipboardData(hBitmap) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44)) pDIB := DllCall("GlobalLock", "Uint", hDIB) DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40) DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44)) DllCall("GlobalUnlock", "Uint", hDIB) DllCall("DeleteObject", "Uint", hBitmap) DllCall("OpenClipboard", "Uint", 0) DllCall("EmptyClipboard") DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB) DllCall("CloseClipboard") }
SaveBMPToFile() { }vs
SaveBMPToFile() { }