Jump to content

Recommended Posts

Posted (edited)

i want to copy a picture file to clipboard, so that i can paste the picture through ctrl+V

this is my code ,but it dosen't work :

#AutoIt3Wrapper_UseX64 = n
#Include <Clipboard.au3>
#include <GDIPlus.au3>


    _GDIPlus_Startup()
    $hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\1.jpg')
    
    
    
    _ClipBoard_Open(0)
    _ClipBoard_SetDataEx($hClipboard_Bitmap,$CF_BITMAP)
    _ClipBoard_Close()
    _GDIPlus_Shutdown()

can you help me

Edited by fenhanxue
Posted
_ClipPutFile("<your filename goes here>")

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

The problem you face is not caused by _ClipPutFile (as it simply writes the file to the clipboard) but the way OICQ handles Ctrl+V.
Run _ClipPutFile and then use Ctrl+V in Word and you'll see what I mean.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 1/15/2018 at 3:14 PM, water said:

The problem you face is not caused by _ClipPutFile (as it simply writes the file to the clipboard) but the way OICQ handles Ctrl+V.
Run _ClipPutFile and then use Ctrl+V in Word and you'll see what I mean.

Expand  

 

IF I  use this code :

$hClipboard_Bitmap = _ScreenCapture_Capture('',0,0,300,300)
    
    _ClipBoard_Open(0)
    _ClipBoard_SetDataEx($hClipboard_Bitmap,$CF_BITMAP)
    _ClipBoard_Close()

Ctrl+V   will   paste the pic in  OICQ 

 

i wonder why  the following code doesn't work:

$hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\Users\s\Desktop\1.jpg')
    
    _ClipBoard_Open(0)
    _ClipBoard_SetDataEx($hClipboard_Bitmap,$CF_BITMAP)
    _ClipBoard_Close()

 

Posted (edited)

Something like this here?

$hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\Users\s\Desktop\1.jpg')
$hClipboard_BitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClipboard_Bitmap)
$hHBmp_Clipboard = _WinAPI_CopyImage($hClipboard_BitmapGDI, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG))

_WinAPI_Bitmap2Clipboard($hHBmp_Clipboard)

Func _WinAPI_Bitmap2Clipboard($hHBitmap)
    If Not _ClipBoard_Open(0) Then Return 1
    If Not _ClipBoard_Empty() Then Return 2
    Local Const $hCP = _ClipBoard_SetDataEx($hHBitmap, $CF_BITMAP)
    If Not $hCP Or @error Then Return 3
    _ClipBoard_Close()
    Return 0
EndFunc

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
  On 1/15/2018 at 3:37 PM, UEZ said:

Something like this here?

$hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile('C:\Users\s\Desktop\1.jpg')
$hClipboard_BitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClipboard_Bitmap)

_WinAPI_Bitmap2Clipboard($hClipboard_BitmapGDI)

Func _WinAPI_Bitmap2Clipboard($hHBitmap)
    If Not _ClipBoard_Open(0) Then Return 1
    If Not _ClipBoard_Empty() Then Return 2
    Local Const $hCP = _ClipBoard_SetDataEx($hHBitmap, $CF_BITMAP)
    If Not $hCP Or @error Then Return 3
    _ClipBoard_Close()
    Return 0
EndFunc

 

Expand  

 

it dosen't work 

Posted (edited)

You have to init GDI+ first of course. Did you?

 

Sorry, I had forgotten one additional line. Check out the code above again.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)
  On 1/15/2018 at 3:45 PM, UEZ said:

You have to init GDI+ first of course. Did you?

 

Sorry, I had forgotten one additional line. Check out the code above again.

Expand  

 

 

Thank you very much 。it works .Thank you 

 

 

Edited by fenhanxue

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
×
×
  • Create New...