Jump to content


Save clipboard image to jpg file

  • Please log in to reply
3 replies to this topic

#1 Max Kipness

Max Kipness


  • Active Members
  • 37 posts

Posted 10 June 2010 - 07:19 PM


Been searching around the forums and found a couple of snippets that other's claim works, but it doesn't seem to be working for me. I'm basically wanting to be able to copy and image to clipboard, or via the snipping tool in Windows 7 and then click a button that saves this to a file so I could do some further processing with it. Here is what I have.\

#include <GUIConstantsEx.au3> #Include <GDIPlus.au3> #include <ClipBoard.au3> #include <ScreenCapture.au3> _Main() Func _Main()     Local $hBmp     ; Capture full screen     $hBmp = _ClipBoard_GetDataEx ($CF_BITMAP )     ; Save bitmap to file     _ScreenCapture_SaveImage (@MyDocumentsDir & "\Image.jpg", $hBmp) EndFunc   ;==>_Main

Can someone please point me in the right direction.


#2 KaFu


    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,422 posts

Posted 10 June 2010 - 10:25 PM

Help-File example is close...CTRL+ALT+s to save screenshot...

#include <ScreenCapture.au3> HotKeySet("{ESC}", "_Exit") HotKeySet("^!s", "_Screenshot") While 1     Sleep(10) WEnd Func _Exit()     Exit EndFunc   ;==>_Exit Func _Screenshot()     Local $hBmp     $hBmp = _ScreenCapture_Capture("")     $file = FileSaveDialog("Save Screenshot", @ScriptDir, "jpg (*.jpg)", 18, "screenshot.jpg")     If Not @error Then _ScreenCapture_SaveImage($file, $hBmp) EndFunc   ;==>_Screenshot

#3 Malkey


  • MVPs
  • 1,593 posts

Posted 10 June 2010 - 10:46 PM

Max Kipness

Your example appears to be trying to combine these two methods.
#include <ScreenCapture.au3> _ScreenCapture_Capture(@ScriptDir & "\GDIPlus_Image.jpg") ShellExecute(@ScriptDir & "\GDIPlus_Image.jpg")
#include <GDIPlus.au3> #include <ClipBoard.au3> ; Capture full screen Send("{PRINTSCREEN}") ; Screen ;Send("!{PRINTSCREEN}") ; window _Main() ShellExecute(@ScriptDir & "\Image.jpg") Func _Main()     Local $hBmp, $hImage     If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed")     $hBmp = _ClipBoard_GetDataEx($CF_BITMAP)     _GDIPlus_Startup()     $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)     ; Save bitmap to file     _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image.jpg") ;$sNewName)     _GDIPlus_BitmapDispose($hImage)     _GDIPlus_Shutdown()     _ClipBoard_Close() EndFunc ;==>_Main

Edited by Malkey, 10 June 2010 - 10:46 PM.

#4 Max Kipness

Max Kipness


  • Active Members
  • 37 posts

Posted 11 June 2010 - 02:31 AM

Thanks Malkey, your second snippet of code included the function that works. I'm not interested in getting screenshots, but rather wanted to get ANY image that might be in the clipboard. So it worked. Thanks again.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users