Jump to content
Sign in to follow this  
Engineer

Screen shot and paste

Recommended Posts

Engineer

Well, I'm trying to find a way to screen shot an active window, then pasting it on a paint document. I have no clue about this and any advice would be apricated.

Share this post


Link to post
Share on other sites
smashly

Hi,

Tried this in win xp, adapt it to suite your needs.

It opens MS Paint, captures the MS Paint window and pastes the capture into the same MS Paint window.

;code by UEZ, adapted by smashly.
#include <Clipboard.au3>
#include <ScreenCapture.au3>

Run("mspaint.exe")
WinWait("[CLASS:MSPaintApp]", "", 5)
WinActivate("[CLASS:MSPaintApp]")

$err = False
$hHBITMAP = _ScreenCapture_CaptureWnd("", WinGetHandle(""))
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
    Send("^v")
Else
    MsgBox(0, "Error", "An error has occured: " & $err_txt, 10)
EndIf

Cheers

Share this post


Link to post
Share on other sites
Engineer

Thank you Smashly. This was exactly what I was looking for.

Edited by Engineer

Share this post


Link to post
Share on other sites
Malkey

Here is a simplified version of smashly's post #3 using MPH's information from post #2.

Send("^{PRINTSCREEN}") ; Capture screen
;Send("!{PRINTSCREEN}") ; Capture current window

Run("mspaint.exe")
WinWait("[CLASS:MSPaintApp]", "", 5)
WinActivate("[CLASS:MSPaintApp]")

Send("^v")

Share this post


Link to post
Share on other sites
UEZ

To capture a region have a look to this:

Br,

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.