Jump to content

How to copy an image file to the clipboard?


Recommended Posts

I'm pretty sure that I am very close here, but it isn't working yet. The calls to user32.dll all seem to work (no MsgBox poping up), but when pasting nothing happens. ^_^

Can anyone point me as to what I'm doing wrong please?

#Include <GDIPlus.au3>

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures\guest.bmp")
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)

$hDll = DllOpen("User32.dll")
$aRet = DllCall($hDll,"int","OpenClipboard","hwnd",0); also tried GUICreate("test"))
if $aRet[0]=0 then exit(msgbox(0,"error","OpenClipboard"))
$aRet = DllCall($hDll,"int","EmptyClipboard")
if $aRet[0]=0 then exit(msgbox(0,"error","EmptyClipboard"))
$aRet = DllCall($hDll,"int","SetClipboardData","int",2,"hwnd",$hBitmap); also tried "ptr"
if $aRet[0]=0 then msgbox(0,"error","SetClipboardData")
$aRet = DllCall($hDll,"int","CloseClipboard")
if $aRet[0]=0 then exit(msgbox(0,"error","CloseClipboard"))
DllClose($hDll)

_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ShutDown()
Link to comment
Share on other sites

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I did not know that, too. I searched a lot and somewhere I found this solution ^_^

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I did not know that, too. I searched a lot and somewhere I found this solution ^_^

BTW, one thing I did find is this:

Func _GDIPlus_ImageCreateGDICompatibleHBITMAP($hImg)
    Local $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg)
    Local $hBitmap = _WinAPI_CopyImage($hBitmap2,0,0,0,$LR_COPYDELETEORG+$LR_COPYRETURNORG)
    _WinAPI_DeleteObject($hBitmap2)  <=- fails, is already deleted?
    Return $hBitmap
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...