Jump to content

Screen capture to clipboard?


Recommended Posts

Hello,

I’m new on this so patience please. What I’m trying to do is to take screen captures of specific window to the clip board and then using another program (than Autoit) to modify it more. First I tried the !{Screen capture}, but it will need a focus to the window being under capture.

So I made this:

#include <ScreenCapture.au3>
#Include <Clipboard.au3>

_Main()

Func _Main()
    Local $hGUI
    Local $hTEST

    ; Create GUI
    $hGUI = GUICreate("Screen Capture", 400, 300)
    GUISetState()
Sleep(1000)
    ; Capture window
    $hTEST = _ScreenCapture_CaptureWnd ("", $hGUI)
    ;$hTEST = _ScreenCapture_CaptureWnd (@MyDocumentsDir & "\GDIPlus_Image.jpg", $hGUI)
Sleep(1000)


_ClipBoard_SetData($hTEST,$CF_BITMAP)

_WinAPI_DeleteObject($hTEST)


EndFunc   ;==>_Main

But it does not work :huh2: I’m guessing it is not even close.

Link to comment
Share on other sites

Try this:

;code by UEZ
#include <Clipboard.au3>
#include <ScreenCapture.au3>
$err = False
$hHBITMAP = _ScreenCapture_Capture("", 0, 0, 100, 100)
If Not _ClipBoard_Open(0) Then
    $err = @error
    $err_txt = "_ClipBoard_Open failed!"
EndIf
If Not _ClipBoard_Empty() Then
    $err = @error
    $err_txt = "_ClipBoard_Empty failed!"
EndIf
If Not _ClipBoard_SetDataEx($hHBITMAP, $CF_BITMAP) Then
    $err = @error
    $err_txt = "_ClipBoard_SetDataEx failed!"
EndIf
_ClipBoard_Close()
_WinAPI_DeleteObject($hHBITMAP)
If Not $err Then
    MsgBox(0, "Information", "Image put to clipboard!", 10)
Else
    MsgBox(0, "Error", "An error has occured: " & $err_txt, 10)
EndIf
Exit

You can change ScreenCapture_Capture() to _ScreenCapture_CaptureWnd(), the result should be the same.

For capturing an area of your desktop you can use this:

Br,

UEZ

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

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...