Sign in to follow this  
Followers 0

Save clipboard image to jpg file

4 posts in this topic

Posted

Hi,

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.

Thanks,

Max

Share this post


Link to post
Share on other sites



Posted

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

Share this post


Link to post
Share on other sites

Posted (edited)

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")
and

#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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0