Jump to content

_CaptureBehindWindow


komalo
 Share

Recommended Posts

hi

this my first script in this forum , it is a tiny script for capture screen

behind a specific window

edit : okay important improvements on the script , now it works like magic

no flushing , no delaying

it works fine for me but not for some users (maybe all) for unknown reasons

so it seems that it will not work for any one but i will leave it here

if any one wanted it

Demo & a Little Function

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

_CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
ShellExecute(@ScriptDir & "\Behind Current window.bmp")

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    Local Const $WS_EX_COMPOSITED = 0x2000000
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow
Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

any opinion ?

Might as well put the includes in there.

#Include <WinAPI.au3>

#Include <ScreenCapture.au3>

#Include <Constants.au3>

edit: Doesn't seem to work quite right. Maybe add a delay till picture is done?

Edited by spudw2k
Link to comment
Share on other sites

Might as well put the includes in there.

#Include <WinAPI.au3>

#Include <ScreenCapture.au3>

#Include <Constants.au3>

edit: Doesn't seem to work quite right. Maybe add a delay till picture is done?

Very buggy =( and you also didnt specify what includes were requires :P

Heres the screenshot that was taken on my system. (only half draws a window)

Posted Image

Good try, but it doesn't work that way.

sorry guys , that's my first script shared here so i didn't know what to do .

i put all the includes now .

about that delay , the script works fine with me but maybe there's timing between

apply the style and taking the screen shot so i modified the script and put a sleep

between SetTrans and capture.

you can try it now .

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

okay important improvements on the script , now it works like magic

no flushing , no delaying , see first post for the update

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

first it works for me fine now so i don't really get it , why it is not captured for you :P

second i am not using GDI Here :(

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

I run the script and absolutely noting happens : /

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")
Link to comment
Share on other sites

I run the script and absolutely noting happens : /

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")
Link to comment
Share on other sites

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")
@Manadar : thank you for replaying to others

now i knew why it wasn't working for you

if you try this

_CaptureBehindWindow("Untitled -", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

with notepad you will not get the flushing

I am XP SP2 User

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

Yeah, so I try this:

;; THE ACTUAL SCRIPT
Opt("WinTitleMatchMode", 2)

WinActivate("Untitled - ")
_CaptureBehindWindow("Untitled -", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

I don't see what the difference is between getting a winhandle using the first part of the string, or the last part of the string. A window handle is a window handle.

Result: You can clearly see where the window was before.

Posted Image

Link to comment
Share on other sites

i am getting board , it works for me that what i want

so i will leave this script here

just for clearing the idea of the script :

bitblt function doesn't get Bits by layered windows

so i get the exstyle of the window and sets the exstyle

to $WS_EX_LAYERED make a screencapture which is

made by bitblt and sets the exstyle to the orginal

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

just for clearing the idea of the script :

bitblt function doesn't get Bits by layered windows

so i get the exstyle of the window and sets the exstyle

to $WS_EX_LAYERED make a screencapture which is

made by bitblt and sets the exstyle to the orginal

You should be able to do this quite effectively using BitBlt and GetDC using a specific hWnd and not null.
Link to comment
Share on other sites

ScreenCapture_Capture Uses Desktop's handle ( _WinAPI_GetDesktopWindow )

and i am able to finish it , what i don't get it

is why it is not working right for you

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
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...