Jump to content

How to copy a picture to the clipboard【solved】


Recommended Posts

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
Link to comment
Share on other sites

_ClipPutFile("<your filename goes here>")

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

7 minutes ago, 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.

 

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()

 

Link to comment
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

6 minutes ago, 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

 

 

it dosen't work 

Link to comment
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

9 minutes ago, 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.

 

 

Thank you very much 。it works .Thank you 

 

 

Edited by fenhanxue
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

×
×
  • Create New...