Jump to content

ScreenCapture


Recommended Posts

I use _ScreenCapture_Capture to capture image from desktop or in active window but my problem is how can I make is be copied in clipboard and automatically show my captured photo in another GUi.Help me please.

Link to comment
Share on other sites

I use _ScreenCapture_Capture to capture image from desktop or in active window but my problem is how can I make is be copied in clipboard and automatically show my captured photo in another GUi.Help me please.

I don't think you can put a picture into the clipboard using AutoIt. However, _ScreenCapture_Capture puts the image into a file. You can simply create a picture object (GUICtrlCreatePic) referencing the same file to display it in another GUI.
Link to comment
Share on other sites

You can put screen captures in the clipboard. Here's an example below, including a fun little way to throw an image on top of any GUI. (just for fun though, as it only lasts until the window redraws)

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

$hCapture = _ScreenCapture_Capture("")  
_ClipBoard_SetData($hCapture, $CF_BITMAP)

Run ("Mspaint")
WinWaitActive("untitled - Paint")
Send("^v")

; Extra fun
_GDIPlus_Startup()

Run("Calc")
WinWaitActive("Calculator")
$hWnd = WinGetHandle("")
$pos = WinGetPos($hWnd)
$hDC = _WinAPI_GetDC($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP ($hCapture)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic,$hBitmap,0,0,@DesktopWidth,@DesktopHeight,0,0,$pos[2],$pos[3])

sleep(3000)

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC (0, $hDC)
_WinAPI_DeleteObject ($hCapture)
_GDIPlus_ImageDispose ($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Link to comment
Share on other sites

Then it's easiest to just do what RodT suggested. Save it to file, then load it into a pic control.

#include <ScreenCapture.au3>
#include <GuiConstants.au3>


$strFile = "\pic.bmp"

_ScreenCapture_Capture(@TempDir & $strFile)

$hWnd = GUICreate("",350,300,-1,-1,$WS_SIZEBOX)
$hPic = GuiCtrlCreatePic(@TempDir & $strFile,0,0,0,0)
GUISetState()

Do
Until GuiGetMsg() = -3

If you don't want it to write to a tempfile... Read through This thread

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